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') 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') 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') 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') 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