includes/sql_parse.php
changeset 863 195920655c6c
parent 801 eb8b23f11744
child 1081 745200a9cc2a
--- a/includes/sql_parse.php	Sat Mar 14 15:25:55 2009 -0400
+++ b/includes/sql_parse.php	Sat Mar 14 15:26:19 2009 -0400
@@ -108,14 +108,14 @@
       $this->sql_array = str_replace("{{{$key}}}", $value, $this->sql_array);
     }
     
-    // Build an array of queries
+    // Strip out comments
     $this->sql_array = explode("\n", $this->sql_array);
     
     foreach ( $this->sql_array as $i => $sql )
     {
       $query =& $this->sql_array[$i];
       $t = trim($query);
-      if ( empty($t) || preg_match('/^(\#|--)/i', $t) )
+      if ( preg_match('/^(\#|--)/i', $t) )
       {
         unset($this->sql_array[$i]);
         unset($query);
@@ -125,11 +125,12 @@
     
     $this->sql_array = array_values($this->sql_array);
     $this->sql_array = implode("\n", $this->sql_array);
-    $this->sql_array = explode(";\n", $this->sql_array);
+    $this->sql_array = explode(";\n", trim($this->sql_array));
     
     foreach ( $this->sql_array as $i => $sql )
     {
       $query =& $this->sql_array[$i];
+      $query = trim($query);
       if ( substr($query, ( strlen($query) - 1 ), 1 ) != ';' )
       {
         $query .= ';';