blob: 4f4f44ba727b2a505b7901513b1286a216f57a41 [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
Greg Aker0defe5d2012-01-01 18:46:41 -060021 * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/)
Timothy Warrend1a5ba22011-10-21 04:45:28 -040022 * @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
toopay59dbcda2011-12-08 20:42:41 +070093 if (strpos($this->hostname, 'sqlite') === FALSE)
94 {
95 $this->hostname .= ";dbname=".$this->database;
96 }
Timothy Warrend1a5ba22011-10-21 04:45:28 -040097
Timothy Warrenab347582011-08-23 12:29:29 -040098 $this->trans_enabled = FALSE;
Timothy Warren80ab8162011-08-22 18:26:12 -040099
100 $this->_random_keyword = ' RND('.time().')'; // database specific random keyword
101 }
102
103 /**
104 * Non-persistent database connection
105 *
106 * @access private called by the base class
107 * @return resource
108 */
109 function db_connect()
110 {
Timothy Warren7aae3682011-10-25 10:37:31 -0400111 $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
Timothy Warrend93393f2011-10-26 11:31:49 -0400112
113 return new PDO($this->hostname, $this->username, $this->password, $this->options);
Timothy Warren80ab8162011-08-22 18:26:12 -0400114 }
115
116 // --------------------------------------------------------------------
117
118 /**
119 * Persistent database connection
120 *
121 * @access private called by the base class
122 * @return resource
123 */
124 function db_pconnect()
125 {
Timothy Warrend93393f2011-10-26 11:31:49 -0400126 $this->options['PDO::ATTR_ERRMODE'] = PDO::ERRMODE_SILENT;
127 $this->options['PDO::ATTR_PERSISTENT'] = TRUE;
128
129 return new PDO($this->hostname, $this->username, $this->password, $this->options);
Timothy Warren80ab8162011-08-22 18:26:12 -0400130 }
131
132 // --------------------------------------------------------------------
133
134 /**
135 * Reconnect
136 *
137 * Keep / reestablish the db connection if no queries have been
138 * sent for a length of time exceeding the server's idle timeout
139 *
140 * @access public
141 * @return void
142 */
143 function reconnect()
144 {
Timothy Warren02615962011-08-24 08:21:36 -0400145 if ($this->db->db_debug)
146 {
147 return $this->db->display_error('db_unsuported_feature');
148 }
149 return FALSE;
Timothy Warren80ab8162011-08-22 18:26:12 -0400150 }
151
152 // --------------------------------------------------------------------
153
154 /**
155 * Select the database
156 *
157 * @access private called by the base class
158 * @return resource
159 */
160 function db_select()
161 {
162 // Not needed for PDO
163 return TRUE;
164 }
165
166 // --------------------------------------------------------------------
167
168 /**
169 * Set client character set
170 *
171 * @access public
172 * @param string
173 * @param string
174 * @return resource
175 */
176 function db_set_charset($charset, $collation)
177 {
178 // @todo - add support if needed
179 return TRUE;
180 }
181
182 // --------------------------------------------------------------------
183
184 /**
185 * Version number query string
186 *
187 * @access public
188 * @return string
189 */
190 function _version()
191 {
Timothy Warren36fb8de2011-08-24 08:29:05 -0400192 return $this->conn_id->getAttribute(PDO::ATTR_CLIENT_VERSION);
Timothy Warren80ab8162011-08-22 18:26:12 -0400193 }
194
195 // --------------------------------------------------------------------
196
197 /**
198 * Execute the query
199 *
200 * @access private called by the base class
201 * @param string an SQL query
Timothy Warren51a48882011-09-14 13:47:06 -0400202 * @return object
Timothy Warren80ab8162011-08-22 18:26:12 -0400203 */
204 function _execute($sql)
205 {
206 $sql = $this->_prep_query($sql);
Timothy Warren51a48882011-09-14 13:47:06 -0400207 $result_id = $this->conn_id->query($sql);
208
Timothy Warrend6691532011-10-07 10:03:01 -0400209 if (is_object($result_id))
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400210 {
211 $this->affect_rows = $result_id->rowCount();
212 }
213 else
214 {
215 $this->affect_rows = 0;
216 }
Timothy Warren51a48882011-09-14 13:47:06 -0400217
218 return $result_id;
Timothy Warren80ab8162011-08-22 18:26:12 -0400219 }
220
221 // --------------------------------------------------------------------
222
223 /**
224 * Prep the query
225 *
226 * If needed, each database adapter can prep the query string
227 *
228 * @access private called by execute()
229 * @param string an SQL query
230 * @return string
231 */
232 function _prep_query($sql)
233 {
234 return $sql;
235 }
236
237 // --------------------------------------------------------------------
238
239 /**
240 * Begin Transaction
241 *
242 * @access public
243 * @return bool
244 */
245 function trans_begin($test_mode = FALSE)
246 {
247 if ( ! $this->trans_enabled)
248 {
249 return TRUE;
250 }
251
252 // When transactions are nested we only begin/commit/rollback the outermost ones
253 if ($this->_trans_depth > 0)
254 {
255 return TRUE;
256 }
257
258 // Reset the transaction failure flag.
259 // If the $test_mode flag is set to TRUE transactions will be rolled back
260 // even if the queries produce a successful result.
Timothy Warrend019fd62011-10-26 11:26:17 -0400261 $this->_trans_failure = (bool) ($test_mode === TRUE);
Timothy Warren80ab8162011-08-22 18:26:12 -0400262
Timothy Warrenab347582011-08-23 12:29:29 -0400263 return $this->conn_id->beginTransaction();
Timothy Warren80ab8162011-08-22 18:26:12 -0400264 }
265
266 // --------------------------------------------------------------------
267
268 /**
269 * Commit Transaction
270 *
271 * @access public
272 * @return bool
273 */
274 function trans_commit()
275 {
276 if ( ! $this->trans_enabled)
277 {
278 return TRUE;
279 }
280
281 // When transactions are nested we only begin/commit/rollback the outermost ones
282 if ($this->_trans_depth > 0)
283 {
284 return TRUE;
285 }
286
Timothy Warrenab347582011-08-23 12:29:29 -0400287 $ret = $this->conn->commit();
Timothy Warren80ab8162011-08-22 18:26:12 -0400288 return $ret;
289 }
290
291 // --------------------------------------------------------------------
292
293 /**
294 * Rollback Transaction
295 *
296 * @access public
297 * @return bool
298 */
299 function trans_rollback()
300 {
301 if ( ! $this->trans_enabled)
302 {
303 return TRUE;
304 }
305
306 // When transactions are nested we only begin/commit/rollback the outermost ones
307 if ($this->_trans_depth > 0)
308 {
309 return TRUE;
310 }
311
Timothy Warrenab347582011-08-23 12:29:29 -0400312 $ret = $this->conn_id->rollBack();
Timothy Warren80ab8162011-08-22 18:26:12 -0400313 return $ret;
314 }
315
316 // --------------------------------------------------------------------
317
318 /**
319 * Escape String
320 *
321 * @access public
322 * @param string
323 * @param bool whether or not the string will be used in a LIKE condition
324 * @return string
325 */
326 function escape_str($str, $like = FALSE)
327 {
328 if (is_array($str))
329 {
330 foreach ($str as $key => $val)
331 {
332 $str[$key] = $this->escape_str($val, $like);
333 }
334
335 return $str;
336 }
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400337
Timothy Warren47663972011-10-05 16:44:50 -0400338 //Escape the string
339 $str = $this->conn_id->quote($str);
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400340
Timothy Warren47663972011-10-05 16:44:50 -0400341 //If there are duplicated quotes, trim them away
Timothy Warrend6691532011-10-07 10:03:01 -0400342 if (strpos($str, "'") === 0)
Timothy Warrenec193322011-10-07 09:53:35 -0400343 {
344 $str = substr($str, 1, -1);
345 }
346
Timothy Warren80ab8162011-08-22 18:26:12 -0400347 // escape LIKE condition wildcards
348 if ($like === TRUE)
349 {
350 $str = str_replace( array('%', '_', $this->_like_escape_chr),
351 array($this->_like_escape_chr.'%', $this->_like_escape_chr.'_', $this->_like_escape_chr.$this->_like_escape_chr),
352 $str);
353 }
354
355 return $str;
356 }
357
358 // --------------------------------------------------------------------
359
360 /**
361 * Affected Rows
362 *
363 * @access public
364 * @return integer
365 */
366 function affected_rows()
367 {
Timothy Warren51a48882011-09-14 13:47:06 -0400368 return $this->affect_rows;
Timothy Warren80ab8162011-08-22 18:26:12 -0400369 }
370
371 // --------------------------------------------------------------------
372
373 /**
374 * Insert ID
Timothy Warren57cea512011-09-14 14:26:28 -0400375 *
Timothy Warren80ab8162011-08-22 18:26:12 -0400376 * @access public
377 * @return integer
378 */
Timothy Warren51a48882011-09-14 13:47:06 -0400379 function insert_id($name=NULL)
Timothy Warren80ab8162011-08-22 18:26:12 -0400380 {
Timothy Warren33512752011-10-07 09:51:49 -0400381 //Convenience method for postgres insertid
Timothy Warrend6691532011-10-07 10:03:01 -0400382 if (strpos($this->hostname, 'pgsql') !== FALSE)
Timothy Warren33512752011-10-07 09:51:49 -0400383 {
384 $v = $this->_version();
385
386 $table = func_num_args() > 0 ? func_get_arg(0) : NULL;
387
388 if ($table == NULL && $v >= '8.1')
389 {
390 $sql='SELECT LASTVAL() as ins_id';
391 }
392 $query = $this->query($sql);
393 $row = $query->row();
394 return $row->ins_id;
395 }
396 else
397 {
398 return $this->conn_id->lastInsertId($name);
399 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400400 }
401
402 // --------------------------------------------------------------------
403
404 /**
405 * "Count All" query
406 *
407 * Generates a platform-specific query string that counts all records in
408 * the specified database
409 *
410 * @access public
411 * @param string
412 * @return string
413 */
414 function count_all($table = '')
415 {
416 if ($table == '')
417 {
418 return 0;
419 }
420
421 $query = $this->query($this->_count_string . $this->_protect_identifiers('numrows') . " FROM " . $this->_protect_identifiers($table, TRUE, NULL, FALSE));
422
423 if ($query->num_rows() == 0)
424 {
425 return 0;
426 }
427
428 $row = $query->row();
429 $this->_reset_select();
430 return (int) $row->numrows;
431 }
432
433 // --------------------------------------------------------------------
434
435 /**
436 * Show table query
437 *
438 * Generates a platform-specific query string so that the table names can be fetched
439 *
440 * @access private
441 * @param boolean
442 * @return string
443 */
444 function _list_tables($prefix_limit = FALSE)
445 {
446 $sql = "SHOW TABLES FROM `".$this->database."`";
447
448 if ($prefix_limit !== FALSE AND $this->dbprefix != '')
449 {
Timothy Warren33512752011-10-07 09:51:49 -0400450 //$sql .= " LIKE '".$this->escape_like_str($this->dbprefix)."%' ".sprintf($this->_like_escape_str, $this->_like_escape_chr);
Timothy Warren80ab8162011-08-22 18:26:12 -0400451 return FALSE; // not currently supported
452 }
453
454 return $sql;
455 }
456
457 // --------------------------------------------------------------------
458
459 /**
460 * Show column query
461 *
462 * Generates a platform-specific query string so that the column names can be fetched
463 *
464 * @access public
465 * @param string the table name
466 * @return string
467 */
468 function _list_columns($table = '')
469 {
470 return "SHOW COLUMNS FROM ".$table;
471 }
472
473 // --------------------------------------------------------------------
474
475 /**
476 * Field data query
477 *
478 * Generates a platform-specific query so that the column data can be retrieved
479 *
480 * @access public
481 * @param string the table name
482 * @return object
483 */
484 function _field_data($table)
485 {
486 return "SELECT TOP 1 FROM ".$table;
487 }
488
489 // --------------------------------------------------------------------
490
491 /**
492 * The error message string
493 *
494 * @access private
495 * @return string
496 */
497 function _error_message()
498 {
Timothy Warrenab347582011-08-23 12:29:29 -0400499 $error_array = $this->conn_id->errorInfo();
500 return $error_array[2];
Timothy Warren80ab8162011-08-22 18:26:12 -0400501 }
502
503 // --------------------------------------------------------------------
504
505 /**
506 * The error message number
507 *
508 * @access private
509 * @return integer
510 */
511 function _error_number()
512 {
Timothy Warrenab347582011-08-23 12:29:29 -0400513 return $this->conn_id->errorCode();
Timothy Warren80ab8162011-08-22 18:26:12 -0400514 }
515
516 // --------------------------------------------------------------------
517
518 /**
519 * Escape the SQL Identifiers
520 *
521 * This function escapes column and table names
522 *
523 * @access private
524 * @param string
525 * @return string
526 */
527 function _escape_identifiers($item)
528 {
529 if ($this->_escape_char == '')
530 {
531 return $item;
532 }
533
534 foreach ($this->_reserved_identifiers as $id)
535 {
536 if (strpos($item, '.'.$id) !== FALSE)
537 {
538 $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item);
539
540 // remove duplicates if the user already included the escape
541 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
542 }
543 }
544
545 if (strpos($item, '.') !== FALSE)
546 {
547 $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item).$this->_escape_char;
Timothy Warren018af7a2011-09-07 12:07:35 -0400548
Timothy Warren80ab8162011-08-22 18:26:12 -0400549 }
550 else
551 {
552 $str = $this->_escape_char.$item.$this->_escape_char;
553 }
554
555 // remove duplicates if the user already included the escape
556 return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str);
557 }
558
559 // --------------------------------------------------------------------
560
561 /**
562 * From Tables
563 *
564 * This function implicitly groups FROM tables so there is no confusion
565 * about operator precedence in harmony with SQL standards
566 *
567 * @access public
568 * @param type
569 * @return type
570 */
571 function _from_tables($tables)
572 {
573 if ( ! is_array($tables))
574 {
575 $tables = array($tables);
576 }
577
Timothy Warrenab347582011-08-23 12:29:29 -0400578 return (count($tables) == 1) ? $tables[0] : '('.implode(', ', $tables).')';
Timothy Warren80ab8162011-08-22 18:26:12 -0400579 }
580
581 // --------------------------------------------------------------------
582
583 /**
584 * Insert statement
585 *
586 * Generates a platform-specific insert string from the supplied data
587 *
588 * @access public
589 * @param string the table name
590 * @param array the insert keys
591 * @param array the insert values
592 * @return string
593 */
594 function _insert($table, $keys, $values)
595 {
596 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES (".implode(', ', $values).")";
597 }
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400598
599 // --------------------------------------------------------------------
600
601 /**
602 * Insert_batch statement
603 *
604 * Generates a platform-specific insert string from the supplied data
605 *
606 * @access public
607 * @param string the table name
608 * @param array the insert keys
609 * @param array the insert values
610 * @return string
611 */
612 function _insert_batch($table, $keys, $values)
613 {
614 return "INSERT INTO ".$table." (".implode(', ', $keys).") VALUES ".implode(', ', $values);
615 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400616
617 // --------------------------------------------------------------------
618
619 /**
620 * Update statement
621 *
622 * Generates a platform-specific update string from the supplied data
623 *
624 * @access public
625 * @param string the table name
626 * @param array the update data
627 * @param array the where clause
628 * @param array the orderby clause
629 * @param array the limit clause
630 * @return string
631 */
632 function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
633 {
634 foreach ($values as $key => $val)
635 {
636 $valstr[] = $key." = ".$val;
637 }
638
639 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
640
641 $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
642
643 $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
644
645 $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
646
647 $sql .= $orderby.$limit;
648
649 return $sql;
650 }
Timothy Warrenb5a43b02011-10-04 17:26:04 -0400651
652 // --------------------------------------------------------------------
653
654 /**
655 * Update_Batch statement
656 *
657 * Generates a platform-specific batch update string from the supplied data
658 *
659 * @access public
660 * @param string the table name
661 * @param array the update data
662 * @param array the where clause
663 * @return string
664 */
665 function _update_batch($table, $values, $index, $where = NULL)
666 {
667 $ids = array();
668 $where = ($where != '' AND count($where) >=1) ? implode(" ", $where).' AND ' : '';
669
670 foreach ($values as $key => $val)
671 {
672 $ids[] = $val[$index];
673
674 foreach (array_keys($val) as $field)
675 {
676 if ($field != $index)
677 {
678 $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field];
679 }
680 }
681 }
682
683 $sql = "UPDATE ".$table." SET ";
684 $cases = '';
685
686 foreach ($final as $k => $v)
687 {
688 $cases .= $k.' = CASE '."\n";
689 foreach ($v as $row)
690 {
691 $cases .= $row."\n";
692 }
693
694 $cases .= 'ELSE '.$k.' END, ';
695 }
696
697 $sql .= substr($cases, 0, -2);
698
699 $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')';
700
701 return $sql;
702 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400703
704
705 // --------------------------------------------------------------------
706
707 /**
708 * Truncate statement
709 *
710 * Generates a platform-specific truncate string from the supplied data
711 * If the database does not support the truncate() command
712 * This function maps to "DELETE FROM table"
713 *
714 * @access public
715 * @param string the table name
716 * @return string
717 */
718 function _truncate($table)
719 {
720 return $this->_delete($table);
721 }
722
723 // --------------------------------------------------------------------
724
725 /**
726 * Delete statement
727 *
728 * Generates a platform-specific delete string from the supplied data
729 *
730 * @access public
731 * @param string the table name
732 * @param array the where clause
733 * @param string the limit clause
734 * @return string
735 */
736 function _delete($table, $where = array(), $like = array(), $limit = FALSE)
737 {
738 $conditions = '';
739
740 if (count($where) > 0 OR count($like) > 0)
741 {
742 $conditions = "\nWHERE ";
743 $conditions .= implode("\n", $this->ar_where);
744
745 if (count($where) > 0 && count($like) > 0)
746 {
747 $conditions .= " AND ";
748 }
749 $conditions .= implode("\n", $like);
750 }
751
752 $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
753
754 return "DELETE FROM ".$table.$conditions.$limit;
755 }
756
757 // --------------------------------------------------------------------
758
759 /**
760 * Limit string
761 *
762 * Generates a platform-specific LIMIT clause
763 *
764 * @access public
765 * @param string the sql query string
766 * @param integer the number of rows to limit the query to
767 * @param integer the offset value
768 * @return string
769 */
770 function _limit($sql, $limit, $offset)
771 {
Timothy Warrend6691532011-10-07 10:03:01 -0400772 if (strpos($this->hostname, 'cubrid') !== FALSE || strpos($this->hostname, 'sqlite') !== FALSE)
Timothy Warren0a43ad82011-09-15 20:15:19 -0400773 {
774 if ($offset == 0)
775 {
776 $offset = '';
777 }
778 else
779 {
780 $offset .= ", ";
781 }
782
783 return $sql."LIMIT ".$offset.$limit;
784 }
785 else
786 {
787 $sql .= "LIMIT ".$limit;
788
789 if ($offset > 0)
790 {
791 $sql .= " OFFSET ".$offset;
792 }
793
794 return $sql;
795 }
Timothy Warren80ab8162011-08-22 18:26:12 -0400796 }
797
798 // --------------------------------------------------------------------
799
800 /**
801 * Close DB Connection
802 *
803 * @access public
804 * @param resource
805 * @return void
806 */
807 function _close($conn_id)
808 {
Timothy Warren6a450cf2011-08-23 12:46:11 -0400809 $this->conn_id = null;
Timothy Warren80ab8162011-08-22 18:26:12 -0400810 }
811
812
813}
814
815
816
817/* End of file pdo_driver.php */
818/* Location: ./system/database/drivers/pdo/pdo_driver.php */