blob: 09277fc39defe513f9ea2cd0047c5ef4bb5f0086 [file] [log] [blame]
Andrey Andreevc5536aa2012-11-01 17:33:58 +02001<?php
Derek Allard2067d1a2008-11-13 22:59:24 +00002/**
3 * CodeIgniter
4 *
Phil Sturgeon07c1ac82012-03-09 17:03:37 +00005 * An open source application development framework for PHP 5.2.4 or newer
Derek Allard2067d1a2008-11-13 22:59:24 +00006 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05007 * NOTICE OF LICENSE
Andrey Andreev1ff49e02012-01-27 11:30:41 +02008 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -05009 * Licensed under the Open Software License version 3.0
Andrey Andreev1ff49e02012-01-27 11:30:41 +020010 *
Derek Jonesf4a4bd82011-10-20 12:18:42 -050011 * 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 *
Derek Allard2067d1a2008-11-13 22:59:24 +000019 * @package CodeIgniter
Derek Jonesf4a4bd82011-10-20 12:18:42 -050020 * @author EllisLab Dev Team
darwinel871754a2014-02-11 17:34:57 +010021 * @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
Derek Jonesf4a4bd82011-10-20 12:18:42 -050022 * @license http://opensource.org/licenses/OSL-3.0 Open Software License (OSL 3.0)
Derek Allard2067d1a2008-11-13 22:59:24 +000023 * @link http://codeigniter.com
24 * @since Version 1.0
25 * @filesource
26 */
Andrey Andreevc5536aa2012-11-01 17:33:58 +020027defined('BASEPATH') OR exit('No direct script access allowed');
Derek Allard2067d1a2008-11-13 22:59:24 +000028
Derek Allard2067d1a2008-11-13 22:59:24 +000029/**
Andrey Andreev1ff49e02012-01-27 11:30:41 +020030 * MySQLi Database Adapter Class
Derek Allard2067d1a2008-11-13 22:59:24 +000031 *
32 * Note: _DB is an extender class that the app controller
Jamie Rumbelow7efad202012-02-19 12:37:00 +000033 * creates dynamically based on whether the query builder
Derek Allard2067d1a2008-11-13 22:59:24 +000034 * class is being used or not.
35 *
36 * @package CodeIgniter
37 * @subpackage Drivers
38 * @category Database
Derek Jonesf4a4bd82011-10-20 12:18:42 -050039 * @author EllisLab Dev Team
Derek Allard2067d1a2008-11-13 22:59:24 +000040 * @link http://codeigniter.com/user_guide/database/
41 */
42class CI_DB_mysqli_driver extends CI_DB {
43
Andrey Andreeva24e52e2012-11-02 03:54:12 +020044 /**
45 * Database driver
46 *
47 * @var string
48 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +020049 public $dbdriver = 'mysqli';
Derek Allard2067d1a2008-11-13 22:59:24 +000050
51 /**
Andrey Andreeva24e52e2012-11-02 03:54:12 +020052 * Compression flag
53 *
54 * @var bool
55 */
56 public $compress = FALSE;
57
58 /**
59 * DELETE hack flag
60 *
Derek Allard2067d1a2008-11-13 22:59:24 +000061 * Whether to use the MySQL "delete hack" which allows the number
62 * of affected rows to be shown. Uses a preg_replace when enabled,
63 * adding a bit more processing to all queries.
Andrey Andreeva24e52e2012-11-02 03:54:12 +020064 *
65 * @var bool
Barry Mienydd671972010-10-04 16:33:58 +020066 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +020067 public $delete_hack = TRUE;
Derek Allard2067d1a2008-11-13 22:59:24 +000068
Andrey Andreevf8f14f32013-12-10 11:32:32 +020069 /**
70 * Strict ON flag
71 *
72 * Whether we're running in strict SQL mode.
73 *
74 * @var bool
75 */
76 public $stricton = FALSE;
77
Andrey Andreeva24e52e2012-11-02 03:54:12 +020078 // --------------------------------------------------------------------
79
Derek Allard2067d1a2008-11-13 22:59:24 +000080 /**
Andrey Andreeva24e52e2012-11-02 03:54:12 +020081 * Identifier escape character
Derek Allard2067d1a2008-11-13 22:59:24 +000082 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +020083 * @var string
84 */
85 protected $_escape_char = '`';
86
87 // --------------------------------------------------------------------
88
89 /**
90 * Database connection
91 *
92 * @param bool $persistent
Andrey Andreev1ff49e02012-01-27 11:30:41 +020093 * @return object
Andrey Andreev2f8bf9b2012-10-12 20:37:52 +030094 * @todo SSL support
Barry Mienydd671972010-10-04 16:33:58 +020095 */
Andrey Andreev2f8bf9b2012-10-12 20:37:52 +030096 public function db_connect($persistent = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +000097 {
Andrey Andreev2f8bf9b2012-10-12 20:37:52 +030098 // Persistent connection support was added in PHP 5.3.0
99 $hostname = ($persistent === TRUE && is_php('5.3'))
100 ? 'p:'.$this->hostname : $this->hostname;
101 $port = empty($this->port) ? NULL : $this->port;
102 $client_flags = ($this->compress === TRUE) ? MYSQLI_CLIENT_COMPRESS : 0;
Andrey Andreev37c85d72012-10-13 17:08:45 +0300103 $mysqli = mysqli_init();
Michiel Vugteveenc27721f2012-08-20 18:34:24 +0200104
Andrey Andreevf8f14f32013-12-10 11:32:32 +0200105 if ($this->stricton)
106 {
107 $mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode="STRICT_ALL_TABLES"');
108 }
109
Andrey Andreevf2818bd2014-02-25 15:26:20 +0200110 return $mysqli->real_connect($hostname, $this->username, $this->password, $this->database, $port, NULL, $client_flags)
Andrey Andreev2f8bf9b2012-10-12 20:37:52 +0300111 ? $mysqli : FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000112 }
113
114 // --------------------------------------------------------------------
115
116 /**
Derek Jones87cbafc2009-02-27 16:29:59 +0000117 * Reconnect
118 *
119 * Keep / reestablish the db connection if no queries have been
120 * sent for a length of time exceeding the server's idle timeout
121 *
Derek Jones87cbafc2009-02-27 16:29:59 +0000122 * @return void
123 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200124 public function reconnect()
Derek Jones87cbafc2009-02-27 16:29:59 +0000125 {
Andrey Andreev992f1752012-03-19 16:58:43 +0200126 if ($this->conn_id !== FALSE && $this->conn_id->ping() === FALSE)
Derek Jones87cbafc2009-02-27 16:29:59 +0000127 {
128 $this->conn_id = FALSE;
129 }
130 }
131
132 // --------------------------------------------------------------------
133
134 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000135 * Select the database
136 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200137 * @param string $database
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200138 * @return bool
Barry Mienydd671972010-10-04 16:33:58 +0200139 */
Andrey Andreev11454e02012-02-22 16:05:47 +0200140 public function db_select($database = '')
Derek Allard2067d1a2008-11-13 22:59:24 +0000141 {
Andrey Andreev024ba2d2012-02-24 11:40:36 +0200142 if ($database === '')
143 {
144 $database = $this->database;
145 }
146
mdunischd3ddf972014-05-07 15:00:40 +0200147 if ($this->conn_id->select_db($database))
Andrey Andreev024ba2d2012-02-24 11:40:36 +0200148 {
149 $this->database = $database;
150 return TRUE;
151 }
152
153 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000154 }
155
156 // --------------------------------------------------------------------
157
158 /**
159 * Set client character set
160 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200161 * @param string $charset
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200162 * @return bool
Derek Allard2067d1a2008-11-13 22:59:24 +0000163 */
Andrey Andreev95bd1d12012-03-12 16:22:28 +0200164 protected function _db_set_charset($charset)
Derek Allard2067d1a2008-11-13 22:59:24 +0000165 {
Andrey Andreev4b90a372014-03-10 10:24:24 +0200166 return $this->conn_id->set_charset($charset);
Derek Allard2067d1a2008-11-13 22:59:24 +0000167 }
168
169 // --------------------------------------------------------------------
Barry Mienydd671972010-10-04 16:33:58 +0200170
Derek Allard2067d1a2008-11-13 22:59:24 +0000171 /**
Andrey Andreev08856b82012-03-03 03:19:28 +0200172 * Database version number
Derek Allard2067d1a2008-11-13 22:59:24 +0000173 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000174 * @return string
175 */
Andrey Andreev08856b82012-03-03 03:19:28 +0200176 public function version()
Derek Allard2067d1a2008-11-13 22:59:24 +0000177 {
Andrey Andreev2b730372012-11-05 17:01:11 +0200178 if (isset($this->data_cache['version']))
179 {
180 return $this->data_cache['version'];
181 }
182 elseif ( ! $this->conn_id)
183 {
184 $this->initialize();
185 }
186
187 return $this->data_cache['version'] = $this->conn_id->server_info;
Derek Allard2067d1a2008-11-13 22:59:24 +0000188 }
189
190 // --------------------------------------------------------------------
191
192 /**
193 * Execute the query
194 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200195 * @param string $sql an SQL query
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200196 * @return mixed
Barry Mienydd671972010-10-04 16:33:58 +0200197 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200198 protected function _execute($sql)
Derek Allard2067d1a2008-11-13 22:59:24 +0000199 {
mdunischd3ddf972014-05-07 15:00:40 +0200200 return $this->conn_id->query($this->_prep_query($sql));
Derek Allard2067d1a2008-11-13 22:59:24 +0000201 }
Barry Mienydd671972010-10-04 16:33:58 +0200202
Derek Allard2067d1a2008-11-13 22:59:24 +0000203 // --------------------------------------------------------------------
204
205 /**
206 * Prep the query
207 *
208 * If needed, each database adapter can prep the query string
209 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200210 * @param string $sql an SQL query
Derek Allard2067d1a2008-11-13 22:59:24 +0000211 * @return string
Barry Mienydd671972010-10-04 16:33:58 +0200212 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200213 protected function _prep_query($sql)
Derek Allard2067d1a2008-11-13 22:59:24 +0000214 {
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200215 // mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack
216 // modifies the query so that it a proper number of affected rows is returned.
217 if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql))
Derek Allard2067d1a2008-11-13 22:59:24 +0000218 {
Andrey Andreevbe999662013-01-10 11:40:09 +0200219 return trim($sql).' WHERE 1=1';
Derek Allard2067d1a2008-11-13 22:59:24 +0000220 }
Barry Mienydd671972010-10-04 16:33:58 +0200221
Derek Allard2067d1a2008-11-13 22:59:24 +0000222 return $sql;
223 }
224
225 // --------------------------------------------------------------------
226
227 /**
228 * Begin Transaction
229 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200230 * @param bool $test_mode
Barry Mienydd671972010-10-04 16:33:58 +0200231 * @return bool
232 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200233 public function trans_begin($test_mode = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000234 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000235 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200236 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000237 {
238 return TRUE;
239 }
240
241 // Reset the transaction failure flag.
242 // If the $test_mode flag is set to TRUE transactions will be rolled back
243 // even if the queries produce a successful result.
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200244 $this->_trans_failure = ($test_mode === TRUE);
Derek Allard2067d1a2008-11-13 22:59:24 +0000245
Andrey Andreev3c5ec852013-09-13 15:01:08 +0300246 $this->conn_id->autocommit(FALSE);
247 return is_php('5.5')
248 ? $this->conn_id->begin_transaction()
249 : $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK
Derek Allard2067d1a2008-11-13 22:59:24 +0000250 }
251
252 // --------------------------------------------------------------------
253
254 /**
255 * Commit Transaction
256 *
Barry Mienydd671972010-10-04 16:33:58 +0200257 * @return bool
258 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200259 public function trans_commit()
Derek Allard2067d1a2008-11-13 22:59:24 +0000260 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000261 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200262 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000263 {
264 return TRUE;
265 }
266
Andrey Andreev3c5ec852013-09-13 15:01:08 +0300267 if ($this->conn_id->commit())
268 {
269 $this->conn_id->autocommit(TRUE);
270 return TRUE;
271 }
272
273 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000274 }
275
276 // --------------------------------------------------------------------
277
278 /**
279 * Rollback Transaction
280 *
Barry Mienydd671972010-10-04 16:33:58 +0200281 * @return bool
282 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200283 public function trans_rollback()
Derek Allard2067d1a2008-11-13 22:59:24 +0000284 {
Derek Allard2067d1a2008-11-13 22:59:24 +0000285 // When transactions are nested we only begin/commit/rollback the outermost ones
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200286 if ( ! $this->trans_enabled OR $this->_trans_depth > 0)
Derek Allard2067d1a2008-11-13 22:59:24 +0000287 {
288 return TRUE;
289 }
290
Andrey Andreev3c5ec852013-09-13 15:01:08 +0300291 if ($this->conn_id->rollback())
292 {
293 $this->conn_id->autocommit(TRUE);
294 return TRUE;
295 }
296
297 return FALSE;
Derek Allard2067d1a2008-11-13 22:59:24 +0000298 }
299
300 // --------------------------------------------------------------------
301
302 /**
Andrey Andreev0b6a4922013-01-10 16:53:44 +0200303 * Platform-dependant string escape
Derek Allard2067d1a2008-11-13 22:59:24 +0000304 *
Andrey Andreev0b6a4922013-01-10 16:53:44 +0200305 * @param string
Derek Allard2067d1a2008-11-13 22:59:24 +0000306 * @return string
307 */
Andrey Andreev0b6a4922013-01-10 16:53:44 +0200308 protected function _escape_str($str)
Derek Allard2067d1a2008-11-13 22:59:24 +0000309 {
Andrey Andreev0b6a4922013-01-10 16:53:44 +0200310 return is_object($this->conn_id)
311 ? $this->conn_id->real_escape_string($str)
312 : addslashes($str);
Derek Allard2067d1a2008-11-13 22:59:24 +0000313 }
Barry Mienydd671972010-10-04 16:33:58 +0200314
Derek Allard2067d1a2008-11-13 22:59:24 +0000315 // --------------------------------------------------------------------
316
317 /**
318 * Affected Rows
319 *
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200320 * @return int
Derek Allard2067d1a2008-11-13 22:59:24 +0000321 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200322 public function affected_rows()
Derek Allard2067d1a2008-11-13 22:59:24 +0000323 {
Andrey Andreev992f1752012-03-19 16:58:43 +0200324 return $this->conn_id->affected_rows;
Derek Allard2067d1a2008-11-13 22:59:24 +0000325 }
Barry Mienydd671972010-10-04 16:33:58 +0200326
Derek Allard2067d1a2008-11-13 22:59:24 +0000327 // --------------------------------------------------------------------
328
329 /**
330 * Insert ID
331 *
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200332 * @return int
Derek Allard2067d1a2008-11-13 22:59:24 +0000333 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200334 public function insert_id()
Derek Allard2067d1a2008-11-13 22:59:24 +0000335 {
Andrey Andreev992f1752012-03-19 16:58:43 +0200336 return $this->conn_id->insert_id;
Derek Allard2067d1a2008-11-13 22:59:24 +0000337 }
338
339 // --------------------------------------------------------------------
340
341 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000342 * List table query
343 *
344 * Generates a platform-specific query string so that the table names can be fetched
345 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200346 * @param bool $prefix_limit
Derek Allard2067d1a2008-11-13 22:59:24 +0000347 * @return string
348 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200349 protected function _list_tables($prefix_limit = FALSE)
Derek Allard2067d1a2008-11-13 22:59:24 +0000350 {
Andrey Andreev473130a2012-06-24 02:51:18 +0300351 $sql = 'SHOW TABLES FROM '.$this->escape_identifiers($this->database);
Barry Mienydd671972010-10-04 16:33:58 +0200352
Alex Bilbie48a2baf2012-06-02 11:09:54 +0100353 if ($prefix_limit !== FALSE && $this->dbprefix !== '')
Derek Allard2067d1a2008-11-13 22:59:24 +0000354 {
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200355 return $sql." LIKE '".$this->escape_like_str($this->dbprefix)."%'";
Derek Allard2067d1a2008-11-13 22:59:24 +0000356 }
Barry Mienydd671972010-10-04 16:33:58 +0200357
Derek Allard2067d1a2008-11-13 22:59:24 +0000358 return $sql;
359 }
360
361 // --------------------------------------------------------------------
362
363 /**
364 * Show column query
365 *
366 * Generates a platform-specific query string so that the column names can be fetched
367 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200368 * @param string $table
Derek Allard2067d1a2008-11-13 22:59:24 +0000369 * @return string
370 */
Andrey Andreev1ff49e02012-01-27 11:30:41 +0200371 protected function _list_columns($table = '')
Derek Allard2067d1a2008-11-13 22:59:24 +0000372 {
Andrey Andreev032e7ea2012-03-06 19:48:35 +0200373 return 'SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE);
Derek Allard2067d1a2008-11-13 22:59:24 +0000374 }
375
376 // --------------------------------------------------------------------
377
378 /**
Andrey Andreev3722e502012-03-03 15:04:38 +0200379 * Returns an object with field data
Derek Allard2067d1a2008-11-13 22:59:24 +0000380 *
Andrey Andreeva24e52e2012-11-02 03:54:12 +0200381 * @param string $table
Andrey Andreev10ecc842012-11-16 01:06:20 +0200382 * @return array
Derek Allard2067d1a2008-11-13 22:59:24 +0000383 */
Andrey Andreev3722e502012-03-03 15:04:38 +0200384 public function field_data($table = '')
Derek Allard2067d1a2008-11-13 22:59:24 +0000385 {
Alex Bilbie48a2baf2012-06-02 11:09:54 +0100386 if ($table === '')
Andrey Andreev3722e502012-03-03 15:04:38 +0200387 {
388 return ($this->db_debug) ? $this->display_error('db_field_param_missing') : FALSE;
389 }
390
Andrey Andreev10ecc842012-11-16 01:06:20 +0200391 if (($query = $this->query('SHOW COLUMNS FROM '.$this->protect_identifiers($table, TRUE, NULL, FALSE))) === FALSE)
392 {
393 return FALSE;
394 }
Andrey Andreev3722e502012-03-03 15:04:38 +0200395 $query = $query->result_object();
396
397 $retval = array();
398 for ($i = 0, $c = count($query); $i < $c; $i++)
399 {
Andrey Andreev3722e502012-03-03 15:04:38 +0200400 $retval[$i] = new stdClass();
401 $retval[$i]->name = $query[$i]->Field;
Andrey Andreev10ecc842012-11-16 01:06:20 +0200402
403 sscanf($query[$i]->Type, '%[a-z](%d)',
404 $retval[$i]->type,
405 $retval[$i]->max_length
406 );
407
Andrey Andreev3722e502012-03-03 15:04:38 +0200408 $retval[$i]->default = $query[$i]->Default;
Andrey Andreev3722e502012-03-03 15:04:38 +0200409 $retval[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
410 }
411
412 return $retval;
Derek Allard2067d1a2008-11-13 22:59:24 +0000413 }
414
415 // --------------------------------------------------------------------
416
417 /**
Andrey Andreev4be5de12012-03-02 15:45:41 +0200418 * Error
Derek Allard2067d1a2008-11-13 22:59:24 +0000419 *
Andrey Andreev4be5de12012-03-02 15:45:41 +0200420 * Returns an array containing code and message of the last
421 * database error that has occured.
Derek Allard2067d1a2008-11-13 22:59:24 +0000422 *
Andrey Andreev4be5de12012-03-02 15:45:41 +0200423 * @return array
Derek Allard2067d1a2008-11-13 22:59:24 +0000424 */
Andrey Andreev4be5de12012-03-02 15:45:41 +0200425 public function error()
Derek Allard2067d1a2008-11-13 22:59:24 +0000426 {
Andrey Andreevdbad54e2012-10-05 21:53:32 +0300427 if ( ! empty($this->conn_id->connect_errno))
428 {
429 return array(
430 'code' => $this->conn_id->connect_errno,
431 'message' => is_php('5.2.9') ? $this->conn_id->connect_error : mysqli_connect_error()
432 );
433 }
434
Andrey Andreev992f1752012-03-19 16:58:43 +0200435 return array('code' => $this->conn_id->errno, 'message' => $this->conn_id->error);
Derek Allard2067d1a2008-11-13 22:59:24 +0000436 }
Barry Mienydd671972010-10-04 16:33:58 +0200437
Derek Allard2067d1a2008-11-13 22:59:24 +0000438 // --------------------------------------------------------------------
439
440 /**
Andrey Andreev7eaa14f2012-10-09 11:34:01 +0300441 * FROM tables
442 *
443 * Groups tables in FROM clauses if needed, so there is no confusion
444 * about operator precedence.
445 *
446 * @return string
447 */
448 protected function _from_tables()
449 {
Andrey Andreevfce9abe2012-10-09 11:37:00 +0300450 if ( ! empty($this->qb_join) && count($this->qb_from) > 1)
Andrey Andreev7eaa14f2012-10-09 11:34:01 +0300451 {
452 return '('.implode(', ', $this->qb_from).')';
453 }
454
455 return implode(', ', $this->qb_from);
456 }
457
458 // --------------------------------------------------------------------
459
460 /**
Derek Allard2067d1a2008-11-13 22:59:24 +0000461 * Close DB Connection
462 *
Derek Allard2067d1a2008-11-13 22:59:24 +0000463 * @return void
464 */
Andrey Andreev79922c02012-05-23 12:27:17 +0300465 protected function _close()
Derek Allard2067d1a2008-11-13 22:59:24 +0000466 {
Andrey Andreev992f1752012-03-19 16:58:43 +0200467 $this->conn_id->close();
Derek Allard2067d1a2008-11-13 22:59:24 +0000468 }
469
Derek Allard2067d1a2008-11-13 22:59:24 +0000470}
471
Derek Allard2067d1a2008-11-13 22:59:24 +0000472/* End of file mysqli_driver.php */
Andrey Andreev79922c02012-05-23 12:27:17 +0300473/* Location: ./system/database/drivers/mysqli/mysqli_driver.php */