Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 1 | <?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 Warren | d1a5ba2 | 2011-10-21 04:45:28 -0400 | [diff] [blame] | 7 | * 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 Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 19 | * @package CodeIgniter |
Timothy Warren | d1a5ba2 | 2011-10-21 04:45:28 -0400 | [diff] [blame] | 20 | * @author EllisLab Dev Team |
Greg Aker | 0defe5d | 2012-01-01 18:46:41 -0600 | [diff] [blame] | 21 | * @copyright Copyright (c) 2008 - 2012, EllisLab, Inc. (http://ellislab.com/) |
Timothy Warren | d1a5ba2 | 2011-10-21 04:45:28 -0400 | [diff] [blame] | 22 | * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0) |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 23 | * @link http://codeigniter.com |
Timothy Warren | 018af7a | 2011-09-07 12:07:35 -0400 | [diff] [blame] | 24 | * @since Version 2.1.0 |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 25 | * @filesource |
| 26 | */ |
| 27 | |
| 28 | // ------------------------------------------------------------------------ |
| 29 | |
| 30 | /** |
Timothy Warren | 0261596 | 2011-08-24 08:21:36 -0400 | [diff] [blame] | 31 | * PDO Database Adapter Class |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 32 | * |
| 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 Warren | d1a5ba2 | 2011-10-21 04:45:28 -0400 | [diff] [blame] | 40 | * @author EllisLab Dev Team |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 41 | * @link http://codeigniter.com/user_guide/database/ |
| 42 | */ |
| 43 | class 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 = ''; |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 49 | |
| 50 | // clause and character used for LIKE escape sequences |
Timothy Warren | c7ba664 | 2011-09-14 12:25:14 -0400 | [diff] [blame] | 51 | var $_like_escape_str; |
| 52 | var $_like_escape_chr; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 53 | |
| 54 | /** |
| 55 | * The syntax to count rows is slightly different across different |
| 56 | * database engines, so this string appears in each driver and is |
| 57 | * used for the count_all() and count_all_results() functions. |
| 58 | */ |
| 59 | var $_count_string = "SELECT COUNT(*) AS "; |
| 60 | var $_random_keyword; |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 61 | |
| 62 | // need to track the pdo DSN, driver and options |
| 63 | var $dsn; |
| 64 | var $pdodriver; |
Timothy Warren | 7aae368 | 2011-10-25 10:37:31 -0400 | [diff] [blame] | 65 | var $options = array(); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 66 | |
Timothy Warren | 51b0e64 | 2011-09-13 13:30:27 -0400 | [diff] [blame] | 67 | function __construct($params) |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 68 | { |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 69 | parent::__construct($params); |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 70 | |
| 71 | if (preg_match('/([^;]+):/', $this->dsn, $match) && count($match) == 2) |
| 72 | { |
| 73 | // If there is a minimum valid dsn string pattern found, we're done |
Taufan Aditya | fdd6ad0 | 2012-02-10 13:10:27 +0700 | [diff] [blame] | 74 | // This is for general PDO users, who tend to have a full DSN string. |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 75 | $this->pdodriver = end($match); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | // Try to build a complete DSN string from params |
| 80 | $this->_connect_string($params); |
| 81 | } |
| 82 | |
Timothy Warren | c7ba664 | 2011-09-14 12:25:14 -0400 | [diff] [blame] | 83 | // clause and character used for LIKE escape sequences |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 84 | // this one depends on the driver being used |
| 85 | if ($this->pdodriver == 'mysql') |
Timothy Warren | c7ba664 | 2011-09-14 12:25:14 -0400 | [diff] [blame] | 86 | { |
| 87 | $this->_like_escape_str = ''; |
| 88 | $this->_like_escape_chr = ''; |
| 89 | } |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 90 | elseif ($this->pdodriver == 'odbc') |
Timothy Warren | c7ba664 | 2011-09-14 12:25:14 -0400 | [diff] [blame] | 91 | { |
| 92 | $this->_like_escape_str = " {escape '%s'} "; |
| 93 | $this->_like_escape_chr = '!'; |
| 94 | } |
| 95 | else |
| 96 | { |
| 97 | $this->_like_escape_str = " ESCAPE '%s' "; |
| 98 | $this->_like_escape_chr = '!'; |
| 99 | } |
| 100 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 101 | $this->trans_enabled = FALSE; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 102 | $this->_random_keyword = ' RND('.time().')'; // database specific random keyword |
| 103 | } |
| 104 | |
| 105 | /** |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 106 | * Connection String |
| 107 | * |
| 108 | * @access private |
| 109 | * @param array |
| 110 | * @return void |
| 111 | */ |
| 112 | function _connect_string($params) |
| 113 | { |
| 114 | if (strpos($this->hostname, ':')) |
| 115 | { |
| 116 | // hostname generally would have this prototype |
| 117 | // $db['hostname'] = 'pdodriver:host(/Server(/DSN))=hostname(/DSN);'; |
| 118 | // We need to get the prefix (pdodriver used by PDO). |
Timothy Warren | 928d83c | 2012-02-13 14:07:57 -0500 | [diff] [blame] | 119 | $dsnarray = explode(':', $this->hostname); |
| 120 | $this->pdodriver = $dsnarray[0]; |
Taufan Aditya | 5dcdbc3 | 2012-02-13 21:15:56 +0700 | [diff] [blame] | 121 | |
| 122 | // End dsn with a semicolon for extra backward compability |
| 123 | // if database property was not empty. |
Timothy Warren | f452469 | 2012-02-13 14:13:28 -0500 | [diff] [blame] | 124 | if ( ! empty($this->database)) |
Timothy Warren | 25dc755 | 2012-02-13 14:12:35 -0500 | [diff] [blame] | 125 | { |
| 126 | $this->dsn .= rtrim($this->hostname, ';').';'; |
| 127 | } |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 128 | } |
| 129 | else |
| 130 | { |
| 131 | // Invalid DSN, display an error |
| 132 | if ( ! array_key_exists('pdodriver', $params)) |
| 133 | { |
| 134 | show_error('Invalid DB Connection String for PDO'); |
| 135 | } |
| 136 | |
| 137 | // Assuming that the following DSN string format is used: |
| 138 | // $dsn = 'pdo://username:password@hostname:port/database?pdodriver=pgsql'; |
| 139 | $this->dsn = $this->pdodriver.':'; |
| 140 | |
| 141 | // Add hostname to the DSN for databases that need it |
Timothy Warren | 928d83c | 2012-02-13 14:07:57 -0500 | [diff] [blame] | 142 | if ( ! empty($this->hostname) |
| 143 | && strpos($this->hostname, ':') === FALSE |
| 144 | && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'sybase', 'mssql', 'dblib', 'cubrid'))) |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 145 | { |
| 146 | $this->dsn .= 'host='.$this->hostname.';'; |
| 147 | } |
| 148 | |
| 149 | // Add a port to the DSN for databases that can use it |
| 150 | if ( ! empty($this->port) && in_array($this->pdodriver, array('informix', 'mysql', 'pgsql', 'ibm', 'cubrid'))) |
| 151 | { |
| 152 | $this->dsn .= 'port='.$this->port.';'; |
| 153 | } |
| 154 | } |
| 155 | |
| 156 | // Add the database name to the DSN, if needed |
| 157 | if (stripos($this->dsn, 'dbname') === FALSE |
| 158 | && in_array($this->pdodriver, array('4D', 'pgsql', 'mysql', 'firebird', 'sybase', 'mssql', 'dblib', 'cubrid'))) |
| 159 | { |
| 160 | $this->dsn .= 'dbname='.$this->database.';'; |
| 161 | } |
| 162 | elseif (stripos($this->dsn, 'database') === FALSE && in_array($this->pdodriver, array('ibm', 'sqlsrv'))) |
| 163 | { |
| 164 | if (stripos($this->dsn, 'dsn') === FALSE) |
| 165 | { |
| 166 | $this->dsn .= 'database='.$this->database.';'; |
| 167 | } |
| 168 | } |
| 169 | elseif ($this->pdodriver === 'sqlite' && $this->dsn === 'sqlite:') |
| 170 | { |
| 171 | if ($this->database !== ':memory') |
| 172 | { |
| 173 | if ( ! file_exists($this->database)) |
| 174 | { |
| 175 | show_error('Invalid DB Connection string for PDO SQLite'); |
| 176 | } |
| 177 | |
| 178 | $this->dsn .= (strpos($this->database, DIRECTORY_SEPARATOR) !== 0) ? DIRECTORY_SEPARATOR : ''; |
| 179 | } |
| 180 | |
| 181 | $this->dsn .= $this->database; |
| 182 | } |
| 183 | |
| 184 | // Add charset to the DSN, if needed |
| 185 | if ( ! empty($this->char_set) && in_array($this->pdodriver, array('4D', 'mysql', 'sybase', 'mssql', 'dblib', 'oci'))) |
| 186 | { |
| 187 | $this->dsn .= 'charset='.$this->char_set.';'; |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | /** |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 192 | * Non-persistent database connection |
| 193 | * |
| 194 | * @access private called by the base class |
| 195 | * @return resource |
| 196 | */ |
| 197 | function db_connect() |
| 198 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 199 | $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; |
| 200 | |
| 201 | return $this->pdo_connect(); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | // -------------------------------------------------------------------- |
| 205 | |
| 206 | /** |
| 207 | * Persistent database connection |
| 208 | * |
| 209 | * @access private called by the base class |
| 210 | * @return resource |
| 211 | */ |
| 212 | function db_pconnect() |
| 213 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 214 | $this->options[PDO::ATTR_ERRMODE] = PDO::ERRMODE_SILENT; |
| 215 | $this->options[PDO::ATTR_PERSISTENT] = TRUE; |
Timothy Warren | d93393f | 2011-10-26 11:31:49 -0400 | [diff] [blame] | 216 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 217 | return $this->pdo_connect(); |
| 218 | } |
| 219 | |
| 220 | // -------------------------------------------------------------------- |
| 221 | |
| 222 | /** |
| 223 | * PDO connection |
| 224 | * |
| 225 | * @access private called by the PDO driver class |
| 226 | * @return resource |
| 227 | */ |
| 228 | function pdo_connect() |
| 229 | { |
Taufan Aditya | 62b8cae | 2012-02-09 16:40:39 +0700 | [diff] [blame] | 230 | // Refer : http://php.net/manual/en/ref.pdo-mysql.connection.php |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 231 | if ($this->pdodriver == 'mysql' && is_php('5.3.6')) |
| 232 | { |
Taufan Aditya | 55bb97e | 2012-02-09 16:43:26 +0700 | [diff] [blame] | 233 | $this->options[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES $this->char_set COLLATE '$this->dbcollat'"; |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 234 | } |
| 235 | |
| 236 | // Connecting... |
| 237 | try |
| 238 | { |
| 239 | $db = new PDO($this->dsn, $this->username, $this->password, $this->options); |
| 240 | } |
| 241 | catch (PDOException $e) |
| 242 | { |
| 243 | if ($this->db_debug && empty($this->failover)) |
| 244 | { |
| 245 | $this->display_error($e->getMessage(), '', TRUE); |
| 246 | } |
| 247 | |
| 248 | return FALSE; |
| 249 | } |
| 250 | |
| 251 | return $db; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 252 | } |
| 253 | |
| 254 | // -------------------------------------------------------------------- |
| 255 | |
| 256 | /** |
| 257 | * Reconnect |
| 258 | * |
| 259 | * Keep / reestablish the db connection if no queries have been |
| 260 | * sent for a length of time exceeding the server's idle timeout |
| 261 | * |
| 262 | * @access public |
| 263 | * @return void |
| 264 | */ |
| 265 | function reconnect() |
| 266 | { |
Timothy Warren | 0261596 | 2011-08-24 08:21:36 -0400 | [diff] [blame] | 267 | if ($this->db->db_debug) |
| 268 | { |
| 269 | return $this->db->display_error('db_unsuported_feature'); |
| 270 | } |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 271 | |
Timothy Warren | 0261596 | 2011-08-24 08:21:36 -0400 | [diff] [blame] | 272 | return FALSE; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | // -------------------------------------------------------------------- |
| 276 | |
| 277 | /** |
| 278 | * Select the database |
| 279 | * |
| 280 | * @access private called by the base class |
| 281 | * @return resource |
| 282 | */ |
| 283 | function db_select() |
| 284 | { |
| 285 | // Not needed for PDO |
| 286 | return TRUE; |
| 287 | } |
| 288 | |
| 289 | // -------------------------------------------------------------------- |
| 290 | |
| 291 | /** |
| 292 | * Set client character set |
| 293 | * |
| 294 | * @access public |
| 295 | * @param string |
| 296 | * @param string |
| 297 | * @return resource |
| 298 | */ |
| 299 | function db_set_charset($charset, $collation) |
| 300 | { |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 301 | return TRUE; |
| 302 | } |
| 303 | |
| 304 | // -------------------------------------------------------------------- |
| 305 | |
| 306 | /** |
| 307 | * Version number query string |
| 308 | * |
| 309 | * @access public |
| 310 | * @return string |
| 311 | */ |
| 312 | function _version() |
| 313 | { |
Timothy Warren | 36fb8de | 2011-08-24 08:29:05 -0400 | [diff] [blame] | 314 | return $this->conn_id->getAttribute(PDO::ATTR_CLIENT_VERSION); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 315 | } |
| 316 | |
| 317 | // -------------------------------------------------------------------- |
| 318 | |
| 319 | /** |
| 320 | * Execute the query |
| 321 | * |
| 322 | * @access private called by the base class |
| 323 | * @param string an SQL query |
Timothy Warren | 51a4888 | 2011-09-14 13:47:06 -0400 | [diff] [blame] | 324 | * @return object |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 325 | */ |
| 326 | function _execute($sql) |
| 327 | { |
| 328 | $sql = $this->_prep_query($sql); |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 329 | |
Timothy Warren | 51a4888 | 2011-09-14 13:47:06 -0400 | [diff] [blame] | 330 | $result_id = $this->conn_id->query($sql); |
| 331 | |
Timothy Warren | d669153 | 2011-10-07 10:03:01 -0400 | [diff] [blame] | 332 | if (is_object($result_id)) |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 333 | { |
| 334 | $this->affect_rows = $result_id->rowCount(); |
| 335 | } |
| 336 | else |
| 337 | { |
| 338 | $this->affect_rows = 0; |
| 339 | } |
Timothy Warren | 51a4888 | 2011-09-14 13:47:06 -0400 | [diff] [blame] | 340 | |
| 341 | return $result_id; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 342 | } |
| 343 | |
| 344 | // -------------------------------------------------------------------- |
| 345 | |
| 346 | /** |
| 347 | * Prep the query |
| 348 | * |
| 349 | * If needed, each database adapter can prep the query string |
| 350 | * |
| 351 | * @access private called by execute() |
| 352 | * @param string an SQL query |
| 353 | * @return string |
| 354 | */ |
| 355 | function _prep_query($sql) |
| 356 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 357 | if ($this->pdodriver === 'pgsql') |
| 358 | { |
| 359 | // Change the backtick(s) for Postgre |
| 360 | $sql = str_replace('`', '"', $sql); |
| 361 | } |
| 362 | elseif ($this->pdodriver === 'sqlite') |
| 363 | { |
| 364 | // Change the backtick(s) for SQLite |
| 365 | $sql = str_replace('`', '', $sql); |
| 366 | } |
| 367 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 368 | return $sql; |
| 369 | } |
| 370 | |
| 371 | // -------------------------------------------------------------------- |
| 372 | |
| 373 | /** |
| 374 | * Begin Transaction |
| 375 | * |
| 376 | * @access public |
| 377 | * @return bool |
| 378 | */ |
| 379 | function trans_begin($test_mode = FALSE) |
| 380 | { |
| 381 | if ( ! $this->trans_enabled) |
| 382 | { |
| 383 | return TRUE; |
| 384 | } |
| 385 | |
| 386 | // When transactions are nested we only begin/commit/rollback the outermost ones |
| 387 | if ($this->_trans_depth > 0) |
| 388 | { |
| 389 | return TRUE; |
| 390 | } |
| 391 | |
| 392 | // Reset the transaction failure flag. |
| 393 | // If the $test_mode flag is set to TRUE transactions will be rolled back |
| 394 | // even if the queries produce a successful result. |
Timothy Warren | d019fd6 | 2011-10-26 11:26:17 -0400 | [diff] [blame] | 395 | $this->_trans_failure = (bool) ($test_mode === TRUE); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 396 | |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 397 | return $this->conn_id->beginTransaction(); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 398 | } |
| 399 | |
| 400 | // -------------------------------------------------------------------- |
| 401 | |
| 402 | /** |
| 403 | * Commit Transaction |
| 404 | * |
| 405 | * @access public |
| 406 | * @return bool |
| 407 | */ |
| 408 | function trans_commit() |
| 409 | { |
| 410 | if ( ! $this->trans_enabled) |
| 411 | { |
| 412 | return TRUE; |
| 413 | } |
| 414 | |
| 415 | // When transactions are nested we only begin/commit/rollback the outermost ones |
| 416 | if ($this->_trans_depth > 0) |
| 417 | { |
| 418 | return TRUE; |
| 419 | } |
| 420 | |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 421 | $ret = $this->conn->commit(); |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 422 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 423 | return $ret; |
| 424 | } |
| 425 | |
| 426 | // -------------------------------------------------------------------- |
| 427 | |
| 428 | /** |
| 429 | * Rollback Transaction |
| 430 | * |
| 431 | * @access public |
| 432 | * @return bool |
| 433 | */ |
| 434 | function trans_rollback() |
| 435 | { |
| 436 | if ( ! $this->trans_enabled) |
| 437 | { |
| 438 | return TRUE; |
| 439 | } |
| 440 | |
| 441 | // When transactions are nested we only begin/commit/rollback the outermost ones |
| 442 | if ($this->_trans_depth > 0) |
| 443 | { |
| 444 | return TRUE; |
| 445 | } |
| 446 | |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 447 | $ret = $this->conn_id->rollBack(); |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 448 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 449 | return $ret; |
| 450 | } |
| 451 | |
| 452 | // -------------------------------------------------------------------- |
| 453 | |
| 454 | /** |
| 455 | * Escape String |
| 456 | * |
| 457 | * @access public |
| 458 | * @param string |
| 459 | * @param bool whether or not the string will be used in a LIKE condition |
| 460 | * @return string |
| 461 | */ |
| 462 | function escape_str($str, $like = FALSE) |
| 463 | { |
| 464 | if (is_array($str)) |
| 465 | { |
| 466 | foreach ($str as $key => $val) |
| 467 | { |
| 468 | $str[$key] = $this->escape_str($val, $like); |
| 469 | } |
| 470 | |
| 471 | return $str; |
| 472 | } |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 473 | |
Timothy Warren | 4766397 | 2011-10-05 16:44:50 -0400 | [diff] [blame] | 474 | //Escape the string |
| 475 | $str = $this->conn_id->quote($str); |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 476 | |
Timothy Warren | 4766397 | 2011-10-05 16:44:50 -0400 | [diff] [blame] | 477 | //If there are duplicated quotes, trim them away |
Timothy Warren | d669153 | 2011-10-07 10:03:01 -0400 | [diff] [blame] | 478 | if (strpos($str, "'") === 0) |
Timothy Warren | ec19332 | 2011-10-07 09:53:35 -0400 | [diff] [blame] | 479 | { |
| 480 | $str = substr($str, 1, -1); |
| 481 | } |
| 482 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 483 | // escape LIKE condition wildcards |
| 484 | if ($like === TRUE) |
| 485 | { |
| 486 | $str = str_replace( array('%', '_', $this->_like_escape_chr), |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 487 | array($this->_like_escape_chr.'%', |
| 488 | $this->_like_escape_chr.'_', |
| 489 | $this->_like_escape_chr.$this->_like_escape_chr), |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 490 | $str); |
| 491 | } |
| 492 | |
| 493 | return $str; |
| 494 | } |
| 495 | |
| 496 | // -------------------------------------------------------------------- |
| 497 | |
| 498 | /** |
| 499 | * Affected Rows |
| 500 | * |
| 501 | * @access public |
| 502 | * @return integer |
| 503 | */ |
| 504 | function affected_rows() |
| 505 | { |
Timothy Warren | 51a4888 | 2011-09-14 13:47:06 -0400 | [diff] [blame] | 506 | return $this->affect_rows; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 507 | } |
| 508 | |
| 509 | // -------------------------------------------------------------------- |
| 510 | |
| 511 | /** |
| 512 | * Insert ID |
Timothy Warren | 57cea51 | 2011-09-14 14:26:28 -0400 | [diff] [blame] | 513 | * |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 514 | * @access public |
| 515 | * @return integer |
| 516 | */ |
Timothy Warren | 51a4888 | 2011-09-14 13:47:06 -0400 | [diff] [blame] | 517 | function insert_id($name=NULL) |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 518 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 519 | if ($this->pdodriver == 'pgsql') |
Timothy Warren | 3351275 | 2011-10-07 09:51:49 -0400 | [diff] [blame] | 520 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 521 | //Convenience method for postgres insertid |
Timothy Warren | 3351275 | 2011-10-07 09:51:49 -0400 | [diff] [blame] | 522 | $v = $this->_version(); |
| 523 | |
| 524 | $table = func_num_args() > 0 ? func_get_arg(0) : NULL; |
| 525 | |
| 526 | if ($table == NULL && $v >= '8.1') |
| 527 | { |
| 528 | $sql='SELECT LASTVAL() as ins_id'; |
| 529 | } |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 530 | |
Timothy Warren | 3351275 | 2011-10-07 09:51:49 -0400 | [diff] [blame] | 531 | $query = $this->query($sql); |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 532 | $row = $query->row(); |
| 533 | |
Timothy Warren | 3351275 | 2011-10-07 09:51:49 -0400 | [diff] [blame] | 534 | return $row->ins_id; |
| 535 | } |
| 536 | else |
| 537 | { |
| 538 | return $this->conn_id->lastInsertId($name); |
| 539 | } |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 540 | } |
| 541 | |
| 542 | // -------------------------------------------------------------------- |
| 543 | |
| 544 | /** |
| 545 | * "Count All" query |
| 546 | * |
| 547 | * Generates a platform-specific query string that counts all records in |
| 548 | * the specified database |
| 549 | * |
| 550 | * @access public |
| 551 | * @param string |
| 552 | * @return string |
| 553 | */ |
| 554 | function count_all($table = '') |
| 555 | { |
| 556 | if ($table == '') |
| 557 | { |
| 558 | return 0; |
| 559 | } |
| 560 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 561 | $sql = $this->_count_string.$this->_protect_identifiers('numrows').' FROM '; |
| 562 | $sql .= $this->_protect_identifiers($table, TRUE, NULL, FALSE); |
| 563 | $query = $this->query($sql); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 564 | |
| 565 | if ($query->num_rows() == 0) |
| 566 | { |
| 567 | return 0; |
| 568 | } |
| 569 | |
| 570 | $row = $query->row(); |
| 571 | $this->_reset_select(); |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 572 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 573 | return (int) $row->numrows; |
| 574 | } |
| 575 | |
| 576 | // -------------------------------------------------------------------- |
| 577 | |
| 578 | /** |
| 579 | * Show table query |
| 580 | * |
| 581 | * Generates a platform-specific query string so that the table names can be fetched |
| 582 | * |
| 583 | * @access private |
| 584 | * @param boolean |
| 585 | * @return string |
| 586 | */ |
| 587 | function _list_tables($prefix_limit = FALSE) |
| 588 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 589 | if ($this->pdodriver == 'pgsql') |
| 590 | { |
| 591 | // Analog function to show all tables in postgre |
| 592 | $sql = "SELECT * FROM information_schema.tables WHERE table_schema = 'public'"; |
| 593 | } |
| 594 | else |
| 595 | { |
| 596 | $sql = "SHOW TABLES FROM `".$this->database."`"; |
| 597 | } |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 598 | |
| 599 | if ($prefix_limit !== FALSE AND $this->dbprefix != '') |
| 600 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 601 | return FALSE; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | return $sql; |
| 605 | } |
| 606 | |
| 607 | // -------------------------------------------------------------------- |
| 608 | |
| 609 | /** |
| 610 | * Show column query |
| 611 | * |
| 612 | * Generates a platform-specific query string so that the column names can be fetched |
| 613 | * |
| 614 | * @access public |
| 615 | * @param string the table name |
| 616 | * @return string |
| 617 | */ |
| 618 | function _list_columns($table = '') |
| 619 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 620 | return 'SHOW COLUMNS FROM '.$this->_from_tables($table); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 621 | } |
| 622 | |
| 623 | // -------------------------------------------------------------------- |
| 624 | |
| 625 | /** |
| 626 | * Field data query |
| 627 | * |
| 628 | * Generates a platform-specific query so that the column data can be retrieved |
| 629 | * |
| 630 | * @access public |
| 631 | * @param string the table name |
| 632 | * @return object |
| 633 | */ |
| 634 | function _field_data($table) |
| 635 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 636 | return 'SELECT TOP 1 FROM '.$this->_from_tables($table); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | // -------------------------------------------------------------------- |
| 640 | |
| 641 | /** |
| 642 | * The error message string |
| 643 | * |
| 644 | * @access private |
| 645 | * @return string |
| 646 | */ |
| 647 | function _error_message() |
| 648 | { |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 649 | $error_array = $this->conn_id->errorInfo(); |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 650 | |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 651 | return $error_array[2]; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 652 | } |
| 653 | |
| 654 | // -------------------------------------------------------------------- |
| 655 | |
| 656 | /** |
| 657 | * The error message number |
| 658 | * |
| 659 | * @access private |
| 660 | * @return integer |
| 661 | */ |
| 662 | function _error_number() |
| 663 | { |
Timothy Warren | ab34758 | 2011-08-23 12:29:29 -0400 | [diff] [blame] | 664 | return $this->conn_id->errorCode(); |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 665 | } |
| 666 | |
| 667 | // -------------------------------------------------------------------- |
| 668 | |
| 669 | /** |
| 670 | * Escape the SQL Identifiers |
| 671 | * |
| 672 | * This function escapes column and table names |
| 673 | * |
| 674 | * @access private |
| 675 | * @param string |
| 676 | * @return string |
| 677 | */ |
| 678 | function _escape_identifiers($item) |
| 679 | { |
| 680 | if ($this->_escape_char == '') |
| 681 | { |
| 682 | return $item; |
| 683 | } |
| 684 | |
| 685 | foreach ($this->_reserved_identifiers as $id) |
| 686 | { |
| 687 | if (strpos($item, '.'.$id) !== FALSE) |
| 688 | { |
| 689 | $str = $this->_escape_char. str_replace('.', $this->_escape_char.'.', $item); |
| 690 | |
| 691 | // remove duplicates if the user already included the escape |
| 692 | return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | if (strpos($item, '.') !== FALSE) |
| 697 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 698 | $str = $this->_escape_char.str_replace('.', $this->_escape_char.'.'.$this->_escape_char, $item); |
| 699 | $str .= $this->_escape_char; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 700 | } |
| 701 | else |
| 702 | { |
| 703 | $str = $this->_escape_char.$item.$this->_escape_char; |
| 704 | } |
| 705 | |
| 706 | // remove duplicates if the user already included the escape |
| 707 | return preg_replace('/['.$this->_escape_char.']+/', $this->_escape_char, $str); |
| 708 | } |
| 709 | |
| 710 | // -------------------------------------------------------------------- |
| 711 | |
| 712 | /** |
| 713 | * From Tables |
| 714 | * |
| 715 | * This function implicitly groups FROM tables so there is no confusion |
| 716 | * about operator precedence in harmony with SQL standards |
| 717 | * |
| 718 | * @access public |
| 719 | * @param type |
| 720 | * @return type |
| 721 | */ |
| 722 | function _from_tables($tables) |
| 723 | { |
| 724 | if ( ! is_array($tables)) |
| 725 | { |
| 726 | $tables = array($tables); |
| 727 | } |
| 728 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 729 | return (count($tables) == 1) ? '`'.$tables[0].'`' : '('.implode(', ', $tables).')'; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 730 | } |
| 731 | |
| 732 | // -------------------------------------------------------------------- |
| 733 | |
| 734 | /** |
| 735 | * Insert statement |
| 736 | * |
| 737 | * Generates a platform-specific insert string from the supplied data |
| 738 | * |
| 739 | * @access public |
| 740 | * @param string the table name |
| 741 | * @param array the insert keys |
| 742 | * @param array the insert values |
| 743 | * @return string |
| 744 | */ |
| 745 | function _insert($table, $keys, $values) |
| 746 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 747 | return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES ('.implode(', ', $values).')'; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 748 | } |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 749 | |
| 750 | // -------------------------------------------------------------------- |
| 751 | |
| 752 | /** |
| 753 | * Insert_batch statement |
| 754 | * |
| 755 | * Generates a platform-specific insert string from the supplied data |
| 756 | * |
| 757 | * @access public |
| 758 | * @param string the table name |
| 759 | * @param array the insert keys |
| 760 | * @param array the insert values |
| 761 | * @return string |
| 762 | */ |
| 763 | function _insert_batch($table, $keys, $values) |
| 764 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 765 | return 'INSERT INTO '.$this->_from_tables($table).' ('.implode(', ', $keys).') VALUES '.implode(', ', $values); |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 766 | } |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 767 | |
| 768 | // -------------------------------------------------------------------- |
| 769 | |
| 770 | /** |
| 771 | * Update statement |
| 772 | * |
| 773 | * Generates a platform-specific update string from the supplied data |
| 774 | * |
| 775 | * @access public |
| 776 | * @param string the table name |
| 777 | * @param array the update data |
| 778 | * @param array the where clause |
| 779 | * @param array the orderby clause |
| 780 | * @param array the limit clause |
| 781 | * @return string |
| 782 | */ |
| 783 | function _update($table, $values, $where, $orderby = array(), $limit = FALSE) |
| 784 | { |
| 785 | foreach ($values as $key => $val) |
| 786 | { |
| 787 | $valstr[] = $key." = ".$val; |
| 788 | } |
| 789 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 790 | $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; |
| 791 | $orderby = (count($orderby) >= 1) ? ' ORDER BY '.implode(', ', $orderby) : ''; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 792 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 793 | $sql = 'UPDATE '.$this->_from_tables($table).' SET '.implode(', ', $valstr); |
| 794 | $sql .= ($where != '' && count($where) >= 1) ? ' WHERE '.implode(' ', $where) : ''; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 795 | $sql .= $orderby.$limit; |
| 796 | |
| 797 | return $sql; |
| 798 | } |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 799 | |
| 800 | // -------------------------------------------------------------------- |
| 801 | |
| 802 | /** |
| 803 | * Update_Batch statement |
| 804 | * |
| 805 | * Generates a platform-specific batch update string from the supplied data |
| 806 | * |
| 807 | * @access public |
| 808 | * @param string the table name |
| 809 | * @param array the update data |
| 810 | * @param array the where clause |
| 811 | * @return string |
| 812 | */ |
| 813 | function _update_batch($table, $values, $index, $where = NULL) |
| 814 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 815 | $ids = array(); |
| 816 | $where = ($where != '' && count($where) >=1) ? implode(" ", $where).' AND ' : ''; |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 817 | |
| 818 | foreach ($values as $key => $val) |
| 819 | { |
| 820 | $ids[] = $val[$index]; |
| 821 | |
| 822 | foreach (array_keys($val) as $field) |
| 823 | { |
| 824 | if ($field != $index) |
| 825 | { |
| 826 | $final[$field][] = 'WHEN '.$index.' = '.$val[$index].' THEN '.$val[$field]; |
| 827 | } |
| 828 | } |
| 829 | } |
| 830 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 831 | $sql = 'UPDATE '.$this->_from_tables($table).' SET '; |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 832 | $cases = ''; |
| 833 | |
| 834 | foreach ($final as $k => $v) |
| 835 | { |
| 836 | $cases .= $k.' = CASE '."\n"; |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 837 | |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 838 | foreach ($v as $row) |
| 839 | { |
| 840 | $cases .= $row."\n"; |
| 841 | } |
| 842 | |
| 843 | $cases .= 'ELSE '.$k.' END, '; |
| 844 | } |
| 845 | |
| 846 | $sql .= substr($cases, 0, -2); |
Timothy Warren | b5a43b0 | 2011-10-04 17:26:04 -0400 | [diff] [blame] | 847 | $sql .= ' WHERE '.$where.$index.' IN ('.implode(',', $ids).')'; |
| 848 | |
| 849 | return $sql; |
| 850 | } |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 851 | |
| 852 | |
| 853 | // -------------------------------------------------------------------- |
| 854 | |
| 855 | /** |
| 856 | * Truncate statement |
| 857 | * |
| 858 | * Generates a platform-specific truncate string from the supplied data |
| 859 | * If the database does not support the truncate() command |
| 860 | * This function maps to "DELETE FROM table" |
| 861 | * |
| 862 | * @access public |
| 863 | * @param string the table name |
| 864 | * @return string |
| 865 | */ |
| 866 | function _truncate($table) |
| 867 | { |
| 868 | return $this->_delete($table); |
| 869 | } |
| 870 | |
| 871 | // -------------------------------------------------------------------- |
| 872 | |
| 873 | /** |
| 874 | * Delete statement |
| 875 | * |
| 876 | * Generates a platform-specific delete string from the supplied data |
| 877 | * |
| 878 | * @access public |
| 879 | * @param string the table name |
| 880 | * @param array the where clause |
| 881 | * @param string the limit clause |
| 882 | * @return string |
| 883 | */ |
| 884 | function _delete($table, $where = array(), $like = array(), $limit = FALSE) |
| 885 | { |
| 886 | $conditions = ''; |
| 887 | |
| 888 | if (count($where) > 0 OR count($like) > 0) |
| 889 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 890 | $conditions = "\nWHERE "; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 891 | $conditions .= implode("\n", $this->ar_where); |
| 892 | |
| 893 | if (count($where) > 0 && count($like) > 0) |
| 894 | { |
| 895 | $conditions .= " AND "; |
| 896 | } |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 897 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 898 | $conditions .= implode("\n", $like); |
| 899 | } |
| 900 | |
| 901 | $limit = ( ! $limit) ? '' : ' LIMIT '.$limit; |
| 902 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 903 | return 'DELETE FROM '.$this->_from_tables($table).$conditions.$limit; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 904 | } |
| 905 | |
| 906 | // -------------------------------------------------------------------- |
| 907 | |
| 908 | /** |
| 909 | * Limit string |
| 910 | * |
| 911 | * Generates a platform-specific LIMIT clause |
| 912 | * |
| 913 | * @access public |
| 914 | * @param string the sql query string |
| 915 | * @param integer the number of rows to limit the query to |
| 916 | * @param integer the offset value |
| 917 | * @return string |
| 918 | */ |
| 919 | function _limit($sql, $limit, $offset) |
| 920 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 921 | if ($this->pdodriver == 'cubrid' OR $this->pdodriver == 'sqlite') |
Timothy Warren | 0a43ad8 | 2011-09-15 20:15:19 -0400 | [diff] [blame] | 922 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 923 | $offset = ($offset == 0) ? '' : $offset.', '; |
Timothy Warren | 0a43ad8 | 2011-09-15 20:15:19 -0400 | [diff] [blame] | 924 | |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 925 | return $sql.'LIMIT '.$offset.$limit; |
Timothy Warren | 0a43ad8 | 2011-09-15 20:15:19 -0400 | [diff] [blame] | 926 | } |
| 927 | else |
| 928 | { |
Taufan Aditya | 1820933 | 2012-02-09 16:07:27 +0700 | [diff] [blame] | 929 | $sql .= 'LIMIT '.$limit; |
| 930 | $sql .= ($offset > 0) ? ' OFFSET '.$offset : ''; |
Timothy Warren | 0a43ad8 | 2011-09-15 20:15:19 -0400 | [diff] [blame] | 931 | |
| 932 | return $sql; |
| 933 | } |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 934 | } |
| 935 | |
| 936 | // -------------------------------------------------------------------- |
| 937 | |
| 938 | /** |
| 939 | * Close DB Connection |
| 940 | * |
| 941 | * @access public |
| 942 | * @param resource |
| 943 | * @return void |
| 944 | */ |
| 945 | function _close($conn_id) |
| 946 | { |
Timothy Warren | 6a450cf | 2011-08-23 12:46:11 -0400 | [diff] [blame] | 947 | $this->conn_id = null; |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 948 | } |
| 949 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 950 | } |
| 951 | |
Timothy Warren | 80ab816 | 2011-08-22 18:26:12 -0400 | [diff] [blame] | 952 | /* End of file pdo_driver.php */ |
| 953 | /* Location: ./system/database/drivers/pdo/pdo_driver.php */ |