@@ -54,67 +54,67 @@ discard block |
||
54 | 54 | * @link https://codeigniter.com/user_guide/database/ |
55 | 55 | */ |
56 | 56 | class CI_DB_mysqli_driver extends CI_DB_driver { |
57 | - /** |
|
58 | - * Database driver |
|
59 | - * |
|
60 | - * @var string |
|
61 | - */ |
|
62 | - public $dbdriver = 'mysqli'; |
|
63 | - /** |
|
64 | - * Compression flag |
|
65 | - * |
|
66 | - * @var bool |
|
67 | - */ |
|
68 | - public $compress = FALSE; |
|
69 | - /** |
|
70 | - * DELETE hack flag |
|
71 | - * |
|
72 | - * Whether to use the MySQL "delete hack" which allows the number |
|
73 | - * of affected rows to be shown. Uses a preg_replace when enabled, |
|
74 | - * adding a bit more processing to all queries. |
|
75 | - * |
|
76 | - * @var bool |
|
77 | - */ |
|
78 | - public $delete_hack = TRUE; |
|
79 | - /** |
|
80 | - * Strict ON flag |
|
81 | - * |
|
82 | - * Whether we're running in strict SQL mode. |
|
83 | - * |
|
84 | - * @var bool |
|
85 | - */ |
|
86 | - public $stricton; |
|
87 | - /** |
|
88 | - * Identifier escape character |
|
89 | - * |
|
90 | - * @var string |
|
91 | - */ |
|
92 | - protected $_escape_char = '`'; |
|
93 | - /** |
|
94 | - * MySQLi object |
|
95 | - * |
|
96 | - * Has to be preserved without being assigned to $conn_id. |
|
97 | - * |
|
98 | - * @var MySQLi |
|
99 | - */ |
|
100 | - protected $_mysqli; |
|
101 | - /** |
|
102 | - * |
|
103 | - * @param array $params |
|
104 | - */ |
|
105 | - public function __construct(array $params) |
|
106 | - { |
|
107 | - parent::__construct($params); |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
111 | - * Database connection |
|
112 | - * |
|
113 | - * @param bool $persistent |
|
114 | - * @return object |
|
115 | - **/ |
|
116 | - public function db_connect($persistent = FALSE) |
|
117 | - { |
|
57 | + /** |
|
58 | + * Database driver |
|
59 | + * |
|
60 | + * @var string |
|
61 | + */ |
|
62 | + public $dbdriver = 'mysqli'; |
|
63 | + /** |
|
64 | + * Compression flag |
|
65 | + * |
|
66 | + * @var bool |
|
67 | + */ |
|
68 | + public $compress = FALSE; |
|
69 | + /** |
|
70 | + * DELETE hack flag |
|
71 | + * |
|
72 | + * Whether to use the MySQL "delete hack" which allows the number |
|
73 | + * of affected rows to be shown. Uses a preg_replace when enabled, |
|
74 | + * adding a bit more processing to all queries. |
|
75 | + * |
|
76 | + * @var bool |
|
77 | + */ |
|
78 | + public $delete_hack = TRUE; |
|
79 | + /** |
|
80 | + * Strict ON flag |
|
81 | + * |
|
82 | + * Whether we're running in strict SQL mode. |
|
83 | + * |
|
84 | + * @var bool |
|
85 | + */ |
|
86 | + public $stricton; |
|
87 | + /** |
|
88 | + * Identifier escape character |
|
89 | + * |
|
90 | + * @var string |
|
91 | + */ |
|
92 | + protected $_escape_char = '`'; |
|
93 | + /** |
|
94 | + * MySQLi object |
|
95 | + * |
|
96 | + * Has to be preserved without being assigned to $conn_id. |
|
97 | + * |
|
98 | + * @var MySQLi |
|
99 | + */ |
|
100 | + protected $_mysqli; |
|
101 | + /** |
|
102 | + * |
|
103 | + * @param array $params |
|
104 | + */ |
|
105 | + public function __construct(array $params) |
|
106 | + { |
|
107 | + parent::__construct($params); |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | + * Database connection |
|
112 | + * |
|
113 | + * @param bool $persistent |
|
114 | + * @return object |
|
115 | + **/ |
|
116 | + public function db_connect($persistent = FALSE) |
|
117 | + { |
|
118 | 118 | // Do we have a socket path? |
119 | 119 | if ($this->hostname[0] === '/') |
120 | 120 | { |
@@ -215,22 +215,22 @@ discard block |
||
215 | 215 | } |
216 | 216 | |
217 | 217 | return FALSE; |
218 | - } |
|
218 | + } |
|
219 | 219 | |
220 | 220 | // -------------------------------------------------------------------- |
221 | 221 | |
222 | - /** |
|
223 | - * Reconnect |
|
224 | - * Keep / reestablish the db connection if no queries have been |
|
225 | - * sent for a length of time exceeding the server's idle timeout |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - public function reconnect() |
|
229 | - { |
|
230 | - if ($this->conn_id !== FALSE && $this->conn_id->ping() === FALSE) { |
|
231 | - $this->conn_id = FALSE; |
|
232 | - } |
|
233 | - } |
|
222 | + /** |
|
223 | + * Reconnect |
|
224 | + * Keep / reestablish the db connection if no queries have been |
|
225 | + * sent for a length of time exceeding the server's idle timeout |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + public function reconnect() |
|
229 | + { |
|
230 | + if ($this->conn_id !== FALSE && $this->conn_id->ping() === FALSE) { |
|
231 | + $this->conn_id = FALSE; |
|
232 | + } |
|
233 | + } |
|
234 | 234 | /** |
235 | 235 | * Select the database |
236 | 236 | * |
@@ -299,33 +299,33 @@ discard block |
||
299 | 299 | |
300 | 300 | // -------------------------------------------------------------------- |
301 | 301 | |
302 | - /** |
|
303 | - * Prep the query |
|
304 | - * |
|
305 | - * If needed, each database adapter can prep the query string |
|
306 | - * |
|
307 | - * @param string $sql an SQL query |
|
308 | - * @return string |
|
309 | - */ |
|
310 | - protected function _prep_query($sql) |
|
311 | - { |
|
312 | - // mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack |
|
313 | - // modifies the query so that it a proper number of affected rows is returned. |
|
314 | - if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) { |
|
315 | - return trim($sql).' WHERE 1=1'; |
|
316 | - } |
|
317 | - return $sql; |
|
318 | - } |
|
319 | - /** |
|
320 | - * Begin Transaction |
|
321 | - * |
|
322 | - * @return bool |
|
323 | - */ |
|
324 | - protected function _trans_begin() |
|
325 | - { |
|
326 | - $this->conn_id->autocommit(FALSE); |
|
327 | - return $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK |
|
328 | - } |
|
302 | + /** |
|
303 | + * Prep the query |
|
304 | + * |
|
305 | + * If needed, each database adapter can prep the query string |
|
306 | + * |
|
307 | + * @param string $sql an SQL query |
|
308 | + * @return string |
|
309 | + */ |
|
310 | + protected function _prep_query($sql) |
|
311 | + { |
|
312 | + // mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack |
|
313 | + // modifies the query so that it a proper number of affected rows is returned. |
|
314 | + if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) { |
|
315 | + return trim($sql).' WHERE 1=1'; |
|
316 | + } |
|
317 | + return $sql; |
|
318 | + } |
|
319 | + /** |
|
320 | + * Begin Transaction |
|
321 | + * |
|
322 | + * @return bool |
|
323 | + */ |
|
324 | + protected function _trans_begin() |
|
325 | + { |
|
326 | + $this->conn_id->autocommit(FALSE); |
|
327 | + return $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK |
|
328 | + } |
|
329 | 329 | |
330 | 330 | // -------------------------------------------------------------------- |
331 | 331 |