From b98c657c100d3220a5d7ed1b6ff3ec78e227b406 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Thu, 7 Jan 2016 16:10:10 +0200 Subject: Fix MySQL's 'stricton' feature --- system/database/drivers/mysql/mysql_driver.php | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index 9c630d0d6..d9c1a98a6 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -147,9 +147,27 @@ class CI_DB_mysql_driver extends CI_DB { : FALSE; } - if ($this->stricton && is_resource($this->conn_id)) + if (isset($this->stricton) && is_resource($this->conn_id)) { - $this->simple_query('SET SESSION sql_mode="STRICT_ALL_TABLES"'); + if ($this->stricton) + { + $this->simple_query('SET SESSION sql_mode = CONCAT(@@sql_mode, ",", "STRICT_ALL_TABLES")'); + } + else + { + $this->simple_query( + 'SET SESSION sql_mode = + REPLACE( + REPLACE( + REPLACE(@@sql_mode, "STRICT_ALL_TABLES,", ""), + ",STRICT_ALL_TABLES", + "" + ), + "STRICT_ALL_TABLES", + "" + )' + ); + } } return $this->conn_id; -- cgit v1.2.3-24-g4f1b