Эх сурвалжийг харах

Fixed:create table sql error

Zhu Jinhui 6 жил өмнө
parent
commit
2d01a549be
1 өөрчлөгдсөн 6 нэмэгдсэн , 3 устгасан
  1. 6 3
      src/Driver/Base.php

+ 6 - 3
src/Driver/Base.php

@@ -331,10 +331,10 @@ class Base
         list($database, $tableName) = array_pad(explode('.', $table), 2, '');
 
         if ($tableName) {
-            $tableName = stristr($tableName, '`') ? $tableName : '`'. $tableName .'`';
+            $tableName = stristr($tableName, '`') || stristr($tableName, " ") ? $tableName : '`'. $tableName .'`';
             return "`{$database}`.`{$tableName}`";
         }
-        $table = stristr($table, '`') ? $table : '`'. $table .'`';
+        $table = stristr($table, '`') || stristr($tableName, " ")  ? $table : '`'. $table .'`';
         return $table;
     }
 
@@ -818,7 +818,10 @@ class Base
     final function createSelectSQL($table)
     {
 
-        if(stristr($table, '.') == false && stristr($table, '`') == false) {
+        if(stristr($table, '.') == false
+            && stristr($table, '`') == false
+            && stristr($table, ' ') == false
+        ) {
             $table = '`'. $table .'`';
         }
         $sql = sprintf($this->_query['SELECT'], ((trim($this->fields) != '') ? $this->fields : "*"), $table) . $this->join . $this->where . $this->groupBy . $this->orderBy . $this->limit;