From 79f888b27bd67724b30aa6dd30e2ae5162b1fea8 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 6 Aug 2013 13:59:23 +0300 Subject: Fix #2501 & another -related bug --- system/database/DB_driver.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 425657e17..53decf014 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1375,7 +1375,9 @@ abstract class CI_DB_driver { $fields[$this->protect_identifiers($key)] = $this->escape($val); } - return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields); + $sql = $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields); + $this->_reset_write(); + return $sql; } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 3a3d5f6c2320a90436de241af41fe22df7344728 Mon Sep 17 00:00:00 2001 From: vlakoff Date: Thu, 17 Oct 2013 22:22:16 +0200 Subject: Replace the last rand() with mt_rand() Better entropy, faster. Also fixed a few "it's" typos. --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 53decf014..618f3660c 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1135,7 +1135,7 @@ abstract class CI_DB_driver { else { /* We have no other choice but to just get the first element's key. - * Due to array_shift() accepting it's argument by reference, if + * Due to array_shift() accepting its argument by reference, if * E_STRICT is on, this would trigger a warning. So we'll have to * assign it first. */ -- cgit v1.2.3-24-g4f1b From 6c85442746c46009cdf3fe517465e174a91cc4c5 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 21 Oct 2013 13:58:15 +0300 Subject: Fix #2691 --- system/database/DB_driver.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 618f3660c..9aa6c5de5 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -624,7 +624,14 @@ abstract class CI_DB_driver { // if transactions are enabled. If we don't call this here // the error message will trigger an exit, causing the // transactions to remain in limbo. - $this->_trans_depth > 0 && $this->trans_complete(); + if ($this->_trans_depth !== 0) + { + do + { + $this->trans_complete(); + } + while ($this->_trans_depth !== 0); + } // Display errors return $this->display_error(array('Error Number: '.$error['code'], $error['message'], $sql)); -- cgit v1.2.3-24-g4f1b From a3f91b9e16ec70a079b8489ffc6a7ff310b35986 Mon Sep 17 00:00:00 2001 From: Kakysha Date: Sat, 14 Dec 2013 05:23:23 +0400 Subject: DB call_function() bug : funny typo -or- smart autocomplete? --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 9aa6c5de5..72be14e4b 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1483,7 +1483,7 @@ abstract class CI_DB_driver { } return (func_num_args() > 1) - ? call_user_func_array($function, array_splice(func_get_args(), 1)) + ? call_user_func_array($function, array_slice(func_get_args(), 1)) : call_user_func($function); } -- cgit v1.2.3-24-g4f1b From 72109068e391d67729d92d23ca47bd6373e64363 Mon Sep 17 00:00:00 2001 From: Tufan Barış YILDIRIM Date: Thu, 19 Dec 2013 19:48:00 +0200 Subject: EXISTS / NOT EXISTS clause support for DB_query_builder. --- system/database/DB_driver.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 72be14e4b..3c30c659c 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1421,7 +1421,7 @@ abstract class CI_DB_driver { */ protected function _has_operator($str) { - return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); + return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|EXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); } // -------------------------------------------------------------------- @@ -1446,7 +1446,9 @@ abstract class CI_DB_driver { '\s*<>?\s*', // <, <> '\s*>\s*', // > '\s+IS NULL', // IS NULL - '\s+IS NOT NULL', // IS NOT NULL + '\s+IS NOT NULL', // IS NOT NULL + '\s+EXISTS', // EXISTS + '\s+NOT EXISTS', // NOT EXISTS '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value '\s+IN\s*\([^\)]+\)', // IN(list) '\s+NOT IN\s*\([^\)]+\)', // NOT IN (list) -- cgit v1.2.3-24-g4f1b From 0f0e6adee7d3edf45fbadf5ec01505a46d70760d Mon Sep 17 00:00:00 2001 From: Tufan Barış YILDIRIM Date: Thu, 19 Dec 2013 19:48:00 +0200 Subject: EXISTS / NOT EXISTS clause support for DB_driver --- system/database/DB_driver.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 72be14e4b..ec3de7e6e 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1421,7 +1421,7 @@ abstract class CI_DB_driver { */ protected function _has_operator($str) { - return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); + return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|EXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); } // -------------------------------------------------------------------- @@ -1446,7 +1446,9 @@ abstract class CI_DB_driver { '\s*<>?\s*', // <, <> '\s*>\s*', // > '\s+IS NULL', // IS NULL - '\s+IS NOT NULL', // IS NOT NULL + '\s+IS NOT NULL', // IS NOT NULL + '\s+EXISTS', // EXISTS + '\s+NOT EXISTS', // NOT EXISTS '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value '\s+IN\s*\([^\)]+\)', // IN(list) '\s+NOT IN\s*\([^\)]+\)', // NOT IN (list) -- cgit v1.2.3-24-g4f1b From 30893b901b9e91c013f86ef733407e17ea084d4c Mon Sep 17 00:00:00 2001 From: Tufan Barış YILDIRIM Date: Thu, 19 Dec 2013 21:30:56 +0200 Subject: changed EXISTS / NOT EXISTS pattern @narfbg "It has parenthesis, so use the IN / NOT IN pattern as a base." --- system/database/DB_driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index ffee74df7..33903434c 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1421,7 +1421,7 @@ abstract class CI_DB_driver { */ protected function _has_operator($str) { - return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|EXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); + return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); } // -------------------------------------------------------------------- @@ -1447,8 +1447,8 @@ abstract class CI_DB_driver { '\s*>\s*', // > '\s+IS NULL', // IS NULL '\s+IS NOT NULL', // IS NOT NULL - '\s+EXISTS', // EXISTS - '\s+NOT EXISTS', // NOT EXISTS + '\s+EXISTS\s*\([^\)]+\)', // EXISTS(sql) + '\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql) '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value '\s+IN\s*\([^\)]+\)', // IN(list) '\s+NOT IN\s*\([^\)]+\)', // NOT IN (list) -- cgit v1.2.3-24-g4f1b From 341532c5d631689c3f9f1a318db598d1ce5344d8 Mon Sep 17 00:00:00 2001 From: Tufan Barış YILDIRIM Date: Thu, 19 Dec 2013 21:32:42 +0200 Subject: so we need \sNOT EXISTS --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 33903434c..ba6a4b70d 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1421,7 +1421,7 @@ abstract class CI_DB_driver { */ protected function _has_operator($str) { - return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); + return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sNOT EXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From 295cfa92574c2ee0c0465e4f86a0d3215a32413c Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Fri, 20 Dec 2013 11:48:38 +0200 Subject: Polishing changes from #PR #2781 Looks like an unnecessary commit was made by the author just as I was clicking the Merge button. :) --- system/database/DB_driver.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index ba6a4b70d..4791c3b89 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -1421,7 +1421,7 @@ abstract class CI_DB_driver { */ protected function _has_operator($str) { - return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sNOT EXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); + return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sEXISTS|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str)); } // -------------------------------------------------------------------- @@ -1446,9 +1446,9 @@ abstract class CI_DB_driver { '\s*<>?\s*', // <, <> '\s*>\s*', // > '\s+IS NULL', // IS NULL - '\s+IS NOT NULL', // IS NOT NULL + '\s+IS NOT NULL', // IS NOT NULL '\s+EXISTS\s*\([^\)]+\)', // EXISTS(sql) - '\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql) + '\s+NOT EXISTS\s*\([^\)]+\)', // NOT EXISTS(sql) '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value '\s+IN\s*\([^\)]+\)', // IN(list) '\s+NOT IN\s*\([^\)]+\)', // NOT IN (list) -- cgit v1.2.3-24-g4f1b From d98c4a3557aa87c02f262f0f7495691f1bc174f0 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Jan 2014 17:33:32 +0200 Subject: A tiny regexp improvement for CI_DB_driver::is_write_type() --- system/database/DB_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/DB_driver.php') diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php index 4791c3b89..f066b58de 100644 --- a/system/database/DB_driver.php +++ b/system/database/DB_driver.php @@ -924,7 +924,7 @@ abstract class CI_DB_driver { */ public function is_write_type($sql) { - return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s+/i', $sql); + return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s/i', $sql); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b