blob: a66a16e90390421af6617aff986aacbb065155c0 [file] [log] [blame]
Timothy Warren80ab8162011-08-22 18:26:12 -04001<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
2/**
3 * CodeIgniter
4 *
5 * An open source application development framework for PHP 5.1.6 or newer
6 *
Timothy Warrend1a5ba22011-10-21 04:45:28 -04007 * NOTICE OF LICENSE
8 *
9 * Licensed under the Open Software License version 3.0
10 *
11 * This source file is subject to the Open Software License (OSL 3.0) that is
12 * bundled with this package in the files license.txt / license.rst. It is
13 * also available through the world wide web at this URL:
14 * http://opensource.org/licenses/OSL-3.0
15 * If you did not receive a copy of the license and are unable to obtain it
16 * through the world wide web, please send an email to
17 * licensing@ellislab.com so we can send you a copy immediately.
18 *
Timothy Warren80ab8162011-08-22 18:26:12 -040019 * @package CodeIgniter
Timothy Warrend1a5ba22011-10-21 04:45:28 -040020 * @author EllisLab Dev Team
21 * @copyright Copyright (c) 2008 - 2011, EllisLab, Inc. (http://ellislab.com/)
22 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Timothy Warren80ab8162011-08-22 18:26:12 -040023 * @link http://codeigniter.com
Timothy Warren018af7a2011-09-07 12:07:35 -040024 * @since Version 2.1.0
Timothy Warren80ab8162011-08-22 18:26:12 -040025 * @filesource
26 */
27
28// ------------------------------------------------------------------------
29
30/**
Timothy Warren02615962011-08-24 08:21:36 -040031 * PDO Database Adapter Class
Timothy Warren80ab8162011-08-22 18:26:12 -040032 *
33 * Note: _DB is an extender class that the app controller
34 * creates dynamically based on whether the active record
35 * class is being used or not.
36 *
37 * @package CodeIgniter
38 * @subpackage Drivers
39 * @category Database
Timothy Warrend1a5ba22011-10-21 04:45:28 -040040 * @author EllisLab Dev Team
Timothy Warren80ab8162011-08-22 18:26:12 -040041 * @link http://codeigniter.com/user_guide/database/
42 */
43class CI_DB_pdo_driver extends CI_DB {
44
45 var $dbdriver = 'pdo';
46
47 // the character used to excape - not necessary for PDO
48 var $_escape_char = '';
Timothy Warrenc7ba6642011-09-14 12:25:14 -040049 var $_like_escape_str;
50 var $_like_escape_chr;
51
Timothy Warren80ab8162011-08-22 18:26:12 -040052
53 /**
54 * The syntax to count rows is slightly different across different
55 * database engines, so this string appears in each driver and is
56 * used for the count_all() and count_all_results() functions.
57 */
58 var $_count_string = "SELECT COUNT(*) AS ";
59 var $_random_keyword;
Timothy Warren7aae3682011-10-25 10:37:31 -040060
61 var $options = array();
Timothy Warren80ab8162011-08-22 18:26:12 -040062
Timothy Warren51b0e642011-09-13 13:30:27 -040063 function __construct($params)
Timothy Warren80ab8162011-08-22 18:26:12 -040064 {
Timothy Warrenb5a43b02011-10-04 17:26:04 -040065 parent::__construct($params);
Timothy Warrenab347582011-08-23 12:29:29 -040066
Timothy Warrenc7ba6642011-09-14 12:25:14 -040067 // clause and character used for LIKE escape sequences
Timothy Warrend6691532011-10-07 10:03:01 -040068 if (strpos($this->hostname, 'mysql') !== FALSE)
Timothy Warrenc7ba6642011-09-14 12:25:14 -040069 {
70 $this->_like_escape_str = '';
71 $this->_like_escape_chr = '';
Timothy Warrend1a5ba22011-10-21 04:45:28 -040072
Timothy Warren7d834be2011-10-26 11:26:17 -040073 //Prior to this version, the charset can't be set in the dsn
74 if(is_php('5.3.6'))
75 {
76 $this->hostname .= ";charset={$this->char_set}";
77 }
78
Timothy Warren7aae3682011-10-25 10:37:31 -040079 //Set the charset with the connection options
80 $this->options['PDO::MYSQL_ATTR_INIT_COMMAND'] = "SET NAMES {$this->char_set}";
Timothy Warrenc7ba6642011-09-14 12:25:14 -040081 }
Timothy Warrend6691532011-10-07 10:03:01 -040082 else if (strpos($this->hostname, 'odbc') !== FALSE)
Timothy Warrenc7ba6642011-09-14 12:25:14 -040083 {
84 $this->_like_escape_str = " {escape '%s'} ";
85 $this->_like_escape_chr = '!';
86 }
87 else
88 {
89 $this->_like_escape_str = " ESCAPE '%s' ";
90 $this->_like_escape_chr = '!';
91 }
92
Timothy Warrend93393f2011-10-26 11:31:49 -040093 $this->hostname .= ";dbname=".$this->database;
Timothy Warrend1a5ba22011-10-21 04:45:28 -040094
Timothy Warrenab347582011-08-23 12:29:29 -040095 $this->trans_enabled = FALSE;
Timothy Warren80ab8162011-08-22 18:26:12 -040096
97 $this->_random_keyword = ' RND('.time().')'; // database specific random keyword
98 }
99
100 /**
101 * Non-persistent database connection
102 *
103 * @access private called by the base class
104 * @return resource
105 */
106 function db_connect()
107 {
Timothy Warren7aae3682011-10-25 10:37:31 -0400108 $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
Timothy Warrend93393f2011-10-26 11:31:49 -0400109
110 return new PDO($this->hostname, $this->username, $this->password, $this->options);
Timothy Warren80ab8162011-08-22 18:26:12 -0400111 }
112
113 // --------------------------------------------------------------------
114
115 /**
116 * Persistent database connection
117 *
118 * @access private called by the base class
119 * @return resource
120 */
121 function db_pconnect()
122 {
Timothy Warrend93393f2011-10-26 11:31:49 -0400123 $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
124 $this->options['PDO::ATTR_PERSISTENT'] = TRUE;
125
126 return new PDO($this->hostname, $this->username, $this->password, $this->options);
Timothy Warren80ab8162011-08-22 18:26:12 -0400127 }
128
129 // --------------------------------------------------------------------
130
131 /**
132 * Reconnect
133 *
134 * Keep / reestablish the db connection if no queries have been
135 * sent for a length of time exceeding the server's idle timeout
136 *
137 * @access public
138 * @return void
139 */
140 function reconnect()
141 {
Timothy Warren02615962011-08-24 08:21:36 -0400142 if ($this->db->db_debug)
143 {
144 return $this->db->display_error('db_unsuported_feature');
145 }
146 return FALSE;
Timothy Warren80ab8162011-08-22 18:26:12 -0400147 }
148
149 // --------------------------------------------------------------------
150
151 /**
152 * Select the database
153 *
154 * @access private called by the base class
155 * @return resource
156 */
157 function db_select()
158 {
159 // Not needed for PDO
160 return TRUE;
161 }
162
163 // --------------------------------------------------------------------
164
165 /**
166 * Set client character set
167 *
168 * @access public
169 * @param string
170 * @param string
171 * @return resource
172 */
173 function db_set_charset($charset, $collation)
174 {
175 // @todo - add support if needed
176 return TRUE;
177 }
178
179 // --------------------------------------------------------------------
180
181 /**
182 * Version number query string
183 *
184 * @access public
185 * @return string
186 */
187 function _version()
188 {
Timothy Warren36fb8de2011-08-24 08:29:05 -0400189 return $this->conn_id->getAttribute(PDO::ATTR_CLIENT_VERSION);
Timothy Warren80ab8162011-08-22 18:26:12 -0400190 }
191
192 // --------------------------------------------------------------------
193
194 /**
195 * Execute the query
196 *
197 * @access private called by the base class
198 * @param string an SQL query
Timothy Warren51a48882011-09-14 13:47:06 -0400199 * @return object
Timothy Warren80ab8162011-08-22 18:26:12 -0400200 */
201 function _execute($sql)
202 {
203 $sql = $this->_prep_query($sql);
Timothy Warren51a48882011-09-14 13:47:06 -0400204 $result_id = $this->conn_id->query($sql);
205
Timothy Warrend6691532011-10-07 10:03:01 -0400206 if (is_object($result_id))
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400207 {
208 $this->affect_rows = $result_id->rowCount();
209 }
210 else
211 {
212 $this->affect_rows = 0;
213 }
Timothy Warren51a48882011-09-14 13:47:06 -0400214
215 return $result_id;
Timothy Warren80ab8162011-08-22 18:26:12 -0400216 }
217
218 // --------------------------------------------------------------------
219
220 /**
221 * Prep the query
222 *
223 * If needed, each database adapter can prep the query string
224 *
225 * @access private called by execute()
226 * @param string an SQL query
227 * @return string
228 */
229 function _prep_query($sql)
230 {
231 return $sql;
232 }
233
234 // --------------------------------------------------------------------
235
236 /**
237 * Begin Transaction
238 *
239 * @access public
240 * @return bool
241 */
242 function trans_begin($test_mode = FALSE)
243 {
244 if ( ! $this->trans_enabled)
245 {
246 return TRUE;
247 }
248
249 // When transactions are nested we only begin/commit/rollback the outermost ones
250 if ($this->_trans_depth > 0)
251 {
252 return TRUE;
253 }
254
255 // Reset the transaction failure flag.
256 // If the $test_mode flag is set to TRUE transactions will be rolled back
257 // even if the queries produce a successful result.
258 $this->_trans_failure = ($test_mode === TRUE) ? TRUE : FALSE;
259
Timothy Warrenab347582011-08-23 12:29:29 -0400260 return $this->conn_id->beginTransaction();
Timothy Warren80ab8162011-08-22 18:26:12 -0400261 }
262
263 // --------------------------------------------------------------------
264
265 /**
266 * Commit Transaction
267 *
268 * @access public
269 * @return bool
270 */
271 function trans_commit()
272 {
273 if ( ! $this->trans_enabled)
274 {
275 return TRUE;
276 }
277
278 // When transactions are nested we only begin/commit/rollback the outermost ones
279 if ($this->_trans_depth > 0)
280 {
281 return TRUE;
282 }
283
Timothy Warrenab347582011-08-23 12:29:29 -0400284 $ret = $this->conn->commit();
Timothy Warren80ab8162011-08-22 18:26:12 -0400285 return $ret;
286 }
287
288 // --------------------------------------------------------------------
289
290 /**
291 * Rollback Transaction
292 *
293 * @access public
294 * @return bool
295 */
296 function trans_rollback()
297 {
298 if ( ! $this->trans_enabled)
299 {
300 return TRUE;
301 }
302
303 // When transactions are nested we only begin/commit/rollback the outermost ones
304 if ($this->_trans_depth > 0)
305 {
306 return TRUE;
307 }
308
Timothy Warrenab347582011-08-23 12:29:29 -0400309 $ret = $this->conn_id->rollBack();
Timothy Warren80ab8162011-08-22 18:26:12 -0400310 return $ret;
311 }
312
313 // --------------------------------------------------------------------
314
315 /**
316 * Escape String
317 *
318 * @access public
319 * @param string
320 * @param bool whether or not the string will be used in a LIKE condition
321 * @return string
322 */
323 function escape_str($str, $like = FALSE)
324 {
325 if (is_array($str))
326 {
327 foreach ($str as $key => $val)
328 {
329 $str[$key] = $this->escape_str($val, $like);
330 }
331
332 return $str;
333 }
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400334
Timothy Warren47663972011-10-05 16:44:50 -0400335 //Escape the string
336 $str = $this->conn_id->quote($str);
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400337
Timothy Warren47663972011-10-05 16:44:50 -0400338 //If there are duplicated quotes, trim them away
Timothy Warrend6691532011-10-07 10:03:01 -0400339 if (strpos($str, "'") === 0)
Timothy Warrenec193322011-10-07 09:53:35 -0400340 {
341 $str = substr($str, 1, -1);
342 }
343
Timothy Warren80ab8162011-08-22 18:26:12 -0400344 // escape LIKE condition wildcards
345 if ($like === TRUE)
346 {
347 $str = str_replace( array('%', '_', $this->_like_escape_chr),
348 array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
349 $str);
350 }
351
352 return $str;
353 }
354
355 // --------------------------------------------------------------------
356
357 /**
358 * Affected Rows
359 *
360 * @access public
361 * @return integer
362 */
363 function affected_rows()
364 {
Timothy Warren51a48882011-09-14 13:47:06 -0400365 return $this->affect_rows;
Timothy Warren80ab8162011-08-22 18:26:12 -0400366 }
367
368 // --------------------------------------------------------------------
369
370 /**
371 * Insert ID
Timothy Warren57cea512011-09-14 14:26:28 -0400372 *
Timothy Warren80ab8162011-08-22 18:26:12 -0400373 * @access public
374 * @return integer
375 */
Timothy Warren51a48882011-09-14 13:47:06 -0400376 function insert_id($name=NULL)
Timothy Warren80ab8162011-08-22 18:26:12 -0400377 {
Timothy Warren33512752011-10-07 09:51:49 -0400378 //Convenience method for postgres insertid
Timothy Warrend6691532011-10-07 10:03:01 -0400379 if (strpos($this->hostname, 'pgsql') !== FALSE)
Timothy Warren33512752011-10-07 09:51:49 -0400380 {
381 $v = $this->_version();
382
383 $table = func_num_args() > 0 ? func_get_arg(0) : NULL;
384
385 if ($table == NULL && $v >= '8.1')
386 {
387 $sql='SELECT LASTVAL() as ins_id';
388 }
389 $query = $this->query($sql);
390 $row = $query->row();
391 return $row->ins_id;
392 }
393 else
394 {
395 return $this->conn_id->lastInsertId($name);
396 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400397 }
398
399 // --------------------------------------------------------------------
400
401 /**
402 * "Count All" query
403 *
404 * Generates a platform-specific query string that counts all records in
405 * the specified database
406 *
407 * @access public
408 * @param string
409 * @return string
410 */
411 function count_all($table = '')
412 {
413 if ($table == '')
414 {
415 return 0;
416 }
417
418 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
419
420 if ($query->num_rows() == 0)
421 {
422 return 0;
423 }
424
425 $row = $query->row();
426 $this->_reset_select();
427 return (int) $row->numrows;
428 }
429
430 // --------------------------------------------------------------------
431
432 /**
433 * Show table query
434 *
435 * Generates a platform-specific query string so that the table names can be fetched
436 *
437 * @access private
438 * @param boolean
439 * @return string
440 */
441 function _list_tables($prefix_limit = FALSE)
442 {
443 $sql = "SHOW TABLES FROM `".$this->database."`";
444
445 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
446 {
Timothy Warren33512752011-10-07 09:51:49 -0400447 //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
Timothy Warren80ab8162011-08-22 18:26:12 -0400448 return FALSE; // not currently supported
449 }
450
451 return $sql;
452 }
453
454 // --------------------------------------------------------------------
455
456 /**
457 * Show column query
458 *
459 * Generates a platform-specific query string so that the column names can be fetched
460 *
461 * @access public
462 * @param string the table name
463 * @return string
464 */
465 function _list_columns($table = '')
466 {
467 return "SHOW COLUMNS FROM ".$table;
468 }
469
470 // --------------------------------------------------------------------
471
472 /**
473 * Field data query
474 *
475 * Generates a platform-specific query so that the column data can be retrieved
476 *
477 * @access public
478 * @param string the table name
479 * @return object
480 */
481 function _field_data($table)
482 {
483 return "SELECT TOP 1 FROM ".$table;
484 }
485
486 // --------------------------------------------------------------------
487
488 /**
489 * The error message string
490 *
491 * @access private
492 * @return string
493 */
494 function _error_message()
495 {
Timothy Warrenab347582011-08-23 12:29:29 -0400496 $error_array = $this->conn_id->errorInfo();
497 return $error_array[2];
Timothy Warren80ab8162011-08-22 18:26:12 -0400498 }
499
500 // --------------------------------------------------------------------
501
502 /**
503 * The error message number
504 *
505 * @access private
506 * @return integer
507 */
508 function _error_number()
509 {
Timothy Warrenab347582011-08-23 12:29:29 -0400510 return $this->conn_id->errorCode();
Timothy Warren80ab8162011-08-22 18:26:12 -0400511 }
512
513 // --------------------------------------------------------------------
514
515 /**
516 * Escape the SQL Identifiers
517 *
518 * This function escapes column and table names
519 *
520 * @access private
521 * @param string
522 * @return string
523 */
524 function _escape_identifiers($item)
525 {
526 if ($this->_escape_char == '')
527 {
528 return $item;
529 }
530
531 foreach ($this->_reserved_identifiers as $id)
532 {
533 if (strpos($item, '.'.$id) !== FALSE)
534 {
535 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
536
537 // remove duplicates if the user already included the escape
538 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
539 }
540 }
541
542 if (strpos($item, '.') !== FALSE)
543 {
544 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
Timothy Warren018af7a2011-09-07 12:07:35 -0400545
Timothy Warren80ab8162011-08-22 18:26:12 -0400546 }
547 else
548 {
549 $str = $this->_escape_char.$item.$this->_escape_char;
550 }
551
552 // remove duplicates if the user already included the escape
553 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
554 }
555
556 // --------------------------------------------------------------------
557
558 /**
559 * From Tables
560 *
561 * This function implicitly groups FROM tables so there is no confusion
562 * about operator precedence in harmony with SQL standards
563 *
564 * @access public
565 * @param type
566 * @return type
567 */
568 function _from_tables($tables)
569 {
570 if ( ! is_array($tables))
571 {
572 $tables = array($tables);
573 }
574
Timothy Warrenab347582011-08-23 12:29:29 -0400575 return (count($tables) == 1) ? $tables[0] : '('.implode(', ', $tables).')';
Timothy Warren80ab8162011-08-22 18:26:12 -0400576 }
577
578 // --------------------------------------------------------------------
579
580 /**
581 * Insert statement
582 *
583 * Generates a platform-specific insert string from the supplied data
584 *
585 * @access public
586 * @param string the table name
587 * @param array the insert keys
588 * @param array the insert values
589 * @return string
590 */
591 function _insert($table, $keys, $values)
592 {
593 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
594 }
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400595
596 // --------------------------------------------------------------------
597
598 /**
599 * Insert_batch statement
600 *
601 * Generates a platform-specific insert string from the supplied data
602 *
603 * @access public
604 * @param string the table name
605 * @param array the insert keys
606 * @param array the insert values
607 * @return string
608 */
609 function _insert_batch($table, $keys, $values)
610 {
611 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
612 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400613
614 // --------------------------------------------------------------------
615
616 /**
617 * Update statement
618 *
619 * Generates a platform-specific update string from the supplied data
620 *
621 * @access public
622 * @param string the table name
623 * @param array the update data
624 * @param array the where clause
625 * @param array the orderby clause
626 * @param array the limit clause
627 * @return string
628 */
629 function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
630 {
631 foreach ($values as $key => $val)
632 {
633 $valstr[] = $key." = ".$val;
634 }
635
636 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
637
638 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
639
640 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
641
642 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
643
644 $sql .= $orderby.$limit;
645
646 return $sql;
647 }
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400648
649 // --------------------------------------------------------------------
650
651 /**
652 * Update_Batch statement
653 *
654 * Generates a platform-specific batch update string from the supplied data
655 *
656 * @access public
657 * @param string the table name
658 * @param array the update data
659 * @param array the where clause
660 * @return string
661 */
662 function _update_batch($table, $values, $index, $where = NULL)
663 {
664 $ids = array();
665 $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
666
667 foreach ($values as $key => $val)
668 {
669 $ids[] = $val[$index];
670
671 foreach (array_keys($val) as $field)
672 {
673 if ($field != $index)
674 {
675 $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
676 }
677 }
678 }
679
680 $sql = "UPDATE ".$table." SET ";
681 $cases = '';
682
683 foreach ($final as $k => $v)
684 {
685 $cases .= $k.' = CASE '."\n";
686 foreach ($v as $row)
687 {
688 $cases .= $row."\n";
689 }
690
691 $cases .= 'ELSE '.$k.' END, ';
692 }
693
694 $sql .= substr($cases, 0, -2);
695
696 $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
697
698 return $sql;
699 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400700
701
702 // --------------------------------------------------------------------
703
704 /**
705 * Truncate statement
706 *
707 * Generates a platform-specific truncate string from the supplied data
708 * If the database does not support the truncate() command
709 * This function maps to "DELETE FROM table"
710 *
711 * @access public
712 * @param string the table name
713 * @return string
714 */
715 function _truncate($table)
716 {
717 return $this->_delete($table);
718 }
719
720 // --------------------------------------------------------------------
721
722 /**
723 * Delete statement
724 *
725 * Generates a platform-specific delete string from the supplied data
726 *
727 * @access public
728 * @param string the table name
729 * @param array the where clause
730 * @param string the limit clause
731 * @return string
732 */
733 function _delete($table, $where = array(), $like = array(), $limit = FALSE)
734 {
735 $conditions = '';
736
737 if (count($where) > 0 OR count($like) > 0)
738 {
739 $conditions = "\nWHERE ";
740 $conditions .= implode("\n", $this->ar_where);
741
742 if (count($where) > 0 && count($like) > 0)
743 {
744 $conditions .= " AND ";
745 }
746 $conditions .= implode("\n", $like);
747 }
748
749 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
750
751 return "DELETE FROM ".$table.$conditions.$limit;
752 }
753
754 // --------------------------------------------------------------------
755
756 /**
757 * Limit string
758 *
759 * Generates a platform-specific LIMIT clause
760 *
761 * @access public
762 * @param string the sql query string
763 * @param integer the number of rows to limit the query to
764 * @param integer the offset value
765 * @return string
766 */
767 function _limit($sql, $limit, $offset)
768 {
Timothy Warrend6691532011-10-07 10:03:01 -0400769 if (strpos($this->hostname, 'cubrid') !== FALSE || strpos($this->hostname, 'sqlite') !== FALSE)
Timothy Warren0a43ad82011-09-15 20:15:19 -0400770 {
771 if ($offset == 0)
772 {
773 $offset = '';
774 }
775 else
776 {
777 $offset .= ", ";
778 }
779
780 return $sql."LIMIT ".$offset.$limit;
781 }
782 else
783 {
784 $sql .= "LIMIT ".$limit;
785
786 if ($offset > 0)
787 {
788 $sql .= " OFFSET ".$offset;
789 }
790
791 return $sql;
792 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400793 }
794
795 // --------------------------------------------------------------------
796
797 /**
798 * Close DB Connection
799 *
800 * @access public
801 * @param resource
802 * @return void
803 */
804 function _close($conn_id)
805 {
Timothy Warren6a450cf2011-08-23 12:46:11 -0400806 $this->conn_id = null;
Timothy Warren80ab8162011-08-22 18:26:12 -0400807 }
808
809
810}
811
812
813
814/* End of file pdo_driver.php */
815/* Location: ./system/database/drivers/pdo/pdo_driver.php */