OSDN Git Service

Debug: MySQL specific comment, '--'
authorkmorimatsu <kmorimatsu@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Thu, 23 Apr 2009 21:48:47 +0000 (21:48 +0000)
committerkmorimatsu <kmorimatsu@1ca29b6e-896d-4ea0-84a5-967f57386b96>
Thu, 23 Apr 2009 21:48:47 +0000 (21:48 +0000)
git-svn-id: https://svn.sourceforge.jp/svnroot/nucleus-jp/plugin@1011 1ca29b6e-896d-4ea0-84a5-967f57386b96

sqlite/trunk/nucleus/sqlite/sqlite.php

index e53cf02..f2b5a8d 100644 (file)
@@ -271,21 +271,27 @@ function sqlite_changeQuote(&$query){
        $ret='';\r
        $qlen=strlen($query);\r
        for ($i=0;$i<$qlen;$i++) {\r
+               // Check MySQL specific comment, '--'.\r
+               $temp=substr($query,$i);\r
+               if (preg_match('/^([^"`\']*)[\r\n]\-\-[\s^\r\n][^\r\n]*/',$temp,$m)) {\r
+                       // Found.\r
+                       $ret.=preg_replace('/[\s]+/',' ',$m[1]); // Change all spacing to ' '.\r
+                       $i += strlen($m[0]);\r
+                       continue;\r
+               }\r
                // Go to next quote\r
                if (($i1=strpos($query,'"',$i))===false) $i1=$qlen;\r
                if (($i2=strpos($query,"'",$i))===false) $i2=$qlen;\r
                if (($i3=strpos($query,'`',$i))===false) $i3=$qlen;\r
                if ($i1==$qlen && $i2==$qlen && $i3==$qlen) {\r
-                       $temp=preg_replace('/[\s]+/',' ',substr($query,$i)); // Change all spacying to ' '.\r
+                       $temp=preg_replace('/[\s]+/',' ',substr($query,$i)); // Change all spacing to ' '.\r
                        $ret.=($temp);\r
                        if (strstr($temp,';')) exit('Warning: try to use more than two queries?');\r
                        break;\r
                }\r
                if ($i2<($j=$i1)) $j=$i2;\r
                if ($i3<$j) $j=$i3;\r
-               $temp=preg_replace('/[\s]+/',' ',substr($query,$i,$j-$i)); // Change all spacying to ' '.\r
-               // Remove MySQL specific comment, '-- '.\r
-               $temp=preg_replace('/($|[\r\n])\-\-[\s^\r\n]([^\r\n]*)/',' ',$temp);\r
+               $temp=preg_replace('/[\s]+/',' ',substr($query,$i,$j-$i)); // Change all spacing to ' '.\r
                $ret.=($temp);\r
                $c=$query[($i=$j)]; // $c keeps the type of quote.\r
                if (strstr($temp,';')) exit('Warning: try to use more than two queries?');\r