OSDN Git Service

Debug: MySQL specific comment, '--'
[nucleus-jp/nucleus-plugins.git] / sqlite / trunk / nucleus / sqlite / sqlite.php
index 271bdb9..f2b5a8d 100644 (file)
@@ -1,7 +1,7 @@
 <?php\r
     /****************************************\r
     * SQLite-MySQL wrapper for Nucleus      *\r
-    *                           ver 0.9.0.4 *\r
+    *                           ver 0.9.0.5 *\r
     * Written by Katsumi                    *\r
     ****************************************/\r
 \r
@@ -13,7 +13,7 @@ if (!function_exists('sqlite_open')) exit('Sorry, SQLite is not available from P
 require_once dirname(__FILE__) . '/sqliteconfig.php';\r
 $SQLITE_DBHANDLE=sqlite_open($SQLITECONF['DBFILENAME']);\r
 require_once dirname(__FILE__) . '/sqlitequeryfunctions.php';\r
-$SQLITECONF['VERSION']='0.9.0.4';\r
+$SQLITECONF['VERSION']='0.9.0.5';\r
 \r
 //Following thing may work if MySQL is NOT installed in server.\r
 if (!function_exists('mysql_query')) {\r
@@ -271,19 +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
+               $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