diff --git a/Library/Think/Db/Driver.php b/Library/Think/Db/Driver.php index 1c9e7dbb..facfe284 100644 --- a/Library/Think/Db/Driver.php +++ b/Library/Think/Db/Driver.php @@ -430,7 +430,7 @@ abstract class Driver { if(!is_numeric($table)) $array[] = $this->parseKey($table).' '.$this->parseKey($alias); else - $array[] = $this->parseKey($table); + $array[] = $this->parseKey($alias); } $tables = $array; }elseif(is_string($tables)){ @@ -563,7 +563,7 @@ abstract class Driver { } }else { //对字符串类型字段采用模糊匹配 - if($this->conf['db_like_fields'] && preg_match('/('.$this->conf['db_like_fields'].')/i',$key)) { + if($this->config['db_like_fields'] && preg_match('/('.$this->config['db_like_fields'].')/i',$key)) { $val = '%'.$val.'%'; $whereStr .= $key.' LIKE '.$this->parseValue($val); }else { diff --git a/Library/Think/Db/Driver/Mysql.php b/Library/Think/Db/Driver/Mysql.php index efa6dc4d..8f1b70bb 100644 --- a/Library/Think/Db/Driver/Mysql.php +++ b/Library/Think/Db/Driver/Mysql.php @@ -42,6 +42,7 @@ class Mysql extends Driver{ */ public function getFields($tableName) { $this->initConnect(true); + list($tableName) = explode(' ', $tableName); $sql = 'SHOW COLUMNS FROM `'.$tableName.'`'; $result = $this->query($sql); $info = []; diff --git a/Library/Think/Db/Driver/Oracle.php b/Library/Think/Db/Driver/Oracle.php index 3b1f5e49..ae77e14f 100644 --- a/Library/Think/Db/Driver/Oracle.php +++ b/Library/Think/Db/Driver/Oracle.php @@ -80,6 +80,7 @@ class Oracle extends Driver{ * @access public */ public function getFields($tableName) { + list($tableName) = explode(' ', $tableName); $result = $this->query("select a.column_name,data_type,decode(nullable,'Y',0,1) notnull,data_default,decode(a.column_name,b.column_name,1,0) pk " ."from user_tab_columns a,(select column_name from user_constraints c,user_cons_columns col " ."where c.constraint_name=col.constraint_name and c.constraint_type='P'and c.table_name='".strtoupper($tableName) diff --git a/Library/Think/Db/Driver/Pgsql.php b/Library/Think/Db/Driver/Pgsql.php index 8dd72cac..dc478103 100644 --- a/Library/Think/Db/Driver/Pgsql.php +++ b/Library/Think/Db/Driver/Pgsql.php @@ -37,6 +37,7 @@ class Pgsql extends Driver{ * @return array */ public function getFields($tableName) { + list($tableName) = explode(' ', $tableName); $result = $this->query('select fields_name as "field",fields_type as "type",fields_not_null as "null",fields_key_name as "key",fields_default as "default",fields_default as "extra" from table_msg('.$tableName.');'); $info = []; if($result){ diff --git a/Library/Think/Db/Driver/Sqlite.php b/Library/Think/Db/Driver/Sqlite.php index fcb77e13..02c0f14a 100644 --- a/Library/Think/Db/Driver/Sqlite.php +++ b/Library/Think/Db/Driver/Sqlite.php @@ -34,6 +34,7 @@ class Sqlite extends Driver { * @return array */ public function getFields($tableName) { + list($tableName) = explode(' ', $tableName); $result = $this->query('PRAGMA table_info( '.$tableName.' )'); $info = []; if($result){ diff --git a/Library/Think/Db/Driver/Sqlsrv.php b/Library/Think/Db/Driver/Sqlsrv.php index 80e73fa8..04e71ad3 100644 --- a/Library/Think/Db/Driver/Sqlsrv.php +++ b/Library/Think/Db/Driver/Sqlsrv.php @@ -46,6 +46,7 @@ class Sqlsrv extends Driver{ * @return array */ public function getFields($tableName) { + list($tableName) = explode(' ', $tableName); $result = $this->query("SELECT column_name, data_type, column_default, is_nullable FROM information_schema.tables AS t JOIN information_schema.columns AS c diff --git a/Library/Think/Model.php b/Library/Think/Model.php index a4254b33..625b4e56 100644 --- a/Library/Think/Model.php +++ b/Library/Think/Model.php @@ -396,7 +396,7 @@ class Model { $options['model'] = $this->name; if(isset($options['table'])) {// 动态指定表名 - $fields = $this->db->getFields($this->options['table']); + $fields = $this->db->getFields($options['table']); $fields = $fields?array_keys($fields):false; }else{ $options['table'] = $this->getTableName();