Fixed SQL error with certain search strings HEAD
authorSami Barakat <sami@sbarakat.co.uk>
Mon, 31 May 2010 23:10:32 +0100
branchHEAD
changeset 7949 c31d64f479d7
parent 7948 617729a5d101
child 7950 45467cb1f1b2
Fixed SQL error with certain search strings
system/classes/listfactory.class.php
--- a/system/classes/listfactory.class.php	Mon May 31 23:04:10 2010 +0100
+++ b/system/classes/listfactory.class.php	Mon May 31 23:10:32 2010 +0100
@@ -336,14 +336,12 @@
         }
 
         if (is_array($sql)) {
-            $sql['mysql'] = preg_replace('/SELECT.*FROM/is', 'SELECT COUNT(*) FROM', $sql['mysql']);
-            $sql['mssql'] = preg_replace('/SELECT.*FROM/is', 'SELECT COUNT(*) FROM', $sql['mssql']);
-            $sql['pgsql'] = preg_replace('/SELECT.*FROM/is', 'SELECT COUNT(*) FROM', $sql['pgsql']);
-
-            
+            $sql['mysql'] = preg_replace('/SELECT.*?FROM/is', 'SELECT COUNT(*) FROM', $sql['mysql']);
+            $sql['mssql'] = preg_replace('/SELECT.*?FROM/is', 'SELECT COUNT(*) FROM', $sql['mssql']);
+            $sql['pgsql'] = preg_replace('/SELECT.*?FROM/is', 'SELECT COUNT(*) FROM', $sql['pgsql']);
         }
         else {
-            $sql = preg_replace('/SELECT.*FROM/is', 'SELECT COUNT(*) FROM', $sql);
+            $sql = preg_replace('/SELECT.*?FROM/is', 'SELECT COUNT(*) FROM', $sql);
         }
         $result = DB_query($sql);
         $num_rows = DB_numRows($result);