diff options
author | Andrey Andreev <narf@devilix.net> | 2016-01-07 16:27:39 +0100 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2016-01-07 16:27:39 +0100 |
commit | c83e894fe8b3c85ff40f00954df0033ad14940b0 (patch) | |
tree | ae209253c858db0fe361b4c647e11a5c4da81ca9 /system/database/drivers/mysqli | |
parent | b98c657c100d3220a5d7ed1b6ff3ec78e227b406 (diff) |
Add MySQL stricton changes to mysqli and pdo/mysql drivers
Diffstat (limited to 'system/database/drivers/mysqli')
-rw-r--r-- | system/database/drivers/mysqli/mysqli_driver.php | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/system/database/drivers/mysqli/mysqli_driver.php b/system/database/drivers/mysqli/mysqli_driver.php index 34366827b..f8694b9d1 100644 --- a/system/database/drivers/mysqli/mysqli_driver.php +++ b/system/database/drivers/mysqli/mysqli_driver.php @@ -84,7 +84,7 @@ class CI_DB_mysqli_driver extends CI_DB { * * @var bool */ - public $stricton = FALSE; + public $stricton; // -------------------------------------------------------------------- @@ -137,9 +137,26 @@ class CI_DB_mysqli_driver extends CI_DB { $this->_mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10); - if ($this->stricton) + if (isset($this->stricton)) { - $this->_mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode="STRICT_ALL_TABLES"'); + if ($this->stricton) + { + $this->_mysqli->options(MYSQLI_INIT_COMMAND, 'SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")'); + } + elseif (version_compare($this->version, '5.7', '>=')) + { + $this->_mysqli->options(MYSQLI_INIT_COMMAND, + 'SET SESSION sql_mode = + REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE( + @@sql_mode, + "STRICT_ALL_TABLES,", ""), + ",STRICT_ALL_TABLES", ""), + "STRICT_ALL_TABLES", ""), + "STRICT_TRANS_TABLES,", ""), + ",STRICT_TRANS_TABLES", ""), + "STRICT_TRANS_TABLES", "")' + ); + } } if (is_array($this->encrypt)) |