@@ -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,7 +215,7 @@ discard block |
||
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | return FALSE; |
| 218 | - } |
|
| 218 | + } |
|
| 219 | 219 | |
| 220 | 220 | // -------------------------------------------------------------------- |
| 221 | 221 | |
@@ -305,33 +305,33 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | // -------------------------------------------------------------------- |
| 307 | 307 | |
| 308 | - /** |
|
| 309 | - * Prep the query |
|
| 310 | - * |
|
| 311 | - * If needed, each database adapter can prep the query string |
|
| 312 | - * |
|
| 313 | - * @param string $sql an SQL query |
|
| 314 | - * @return string |
|
| 315 | - */ |
|
| 316 | - protected function _prep_query($sql) |
|
| 317 | - { |
|
| 318 | - // mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack |
|
| 319 | - // modifies the query so that it a proper number of affected rows is returned. |
|
| 320 | - if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) { |
|
| 321 | - return trim($sql).' WHERE 1=1'; |
|
| 322 | - } |
|
| 323 | - return $sql; |
|
| 324 | - } |
|
| 325 | - /** |
|
| 326 | - * Begin Transaction |
|
| 327 | - * |
|
| 328 | - * @return bool |
|
| 329 | - */ |
|
| 330 | - protected function _trans_begin() |
|
| 331 | - { |
|
| 332 | - $this->conn_id->autocommit(FALSE); |
|
| 333 | - return $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK |
|
| 334 | - } |
|
| 308 | + /** |
|
| 309 | + * Prep the query |
|
| 310 | + * |
|
| 311 | + * If needed, each database adapter can prep the query string |
|
| 312 | + * |
|
| 313 | + * @param string $sql an SQL query |
|
| 314 | + * @return string |
|
| 315 | + */ |
|
| 316 | + protected function _prep_query($sql) |
|
| 317 | + { |
|
| 318 | + // mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack |
|
| 319 | + // modifies the query so that it a proper number of affected rows is returned. |
|
| 320 | + if ($this->delete_hack === TRUE && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) { |
|
| 321 | + return trim($sql).' WHERE 1=1'; |
|
| 322 | + } |
|
| 323 | + return $sql; |
|
| 324 | + } |
|
| 325 | + /** |
|
| 326 | + * Begin Transaction |
|
| 327 | + * |
|
| 328 | + * @return bool |
|
| 329 | + */ |
|
| 330 | + protected function _trans_begin() |
|
| 331 | + { |
|
| 332 | + $this->conn_id->autocommit(FALSE); |
|
| 333 | + return $this->simple_query('START TRANSACTION'); // can also be BEGIN or BEGIN WORK |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | 336 | // -------------------------------------------------------------------- |
| 337 | 337 | |