修正Query类的gettableinfo方法

This commit is contained in:
thinkphp
2016-06-20 10:56:30 +08:00
parent ff16a4521d
commit 1e6cd85c04

View File

@@ -47,6 +47,8 @@ class Query
protected $options = []; protected $options = [];
// 参数绑定 // 参数绑定
protected $bind = []; protected $bind = [];
// 数据表信息
protected $info = [];
/** /**
* 架构函数 * 架构函数
@@ -1284,7 +1286,6 @@ class Query
*/ */
public function getTableInfo($tableName = '', $fetch = '') public function getTableInfo($tableName = '', $fetch = '')
{ {
static $_info = [];
if (!$tableName) { if (!$tableName) {
$tableName = $this->getTable(); $tableName = $this->getTable();
} }
@@ -1299,8 +1300,8 @@ class Query
$tableName = $this->parseSqlTable($tableName); $tableName = $this->parseSqlTable($tableName);
} }
$guid = md5($tableName); $guid = $tableName;
if (!isset($_info[$guid])) { if (!isset($this->info[$guid])) {
$info = $this->connection->getFields($tableName); $info = $this->connection->getFields($tableName);
$fields = array_keys($info); $fields = array_keys($info);
$bind = $type = []; $bind = $type = [];
@@ -1324,10 +1325,9 @@ class Query
} else { } else {
$pk = null; $pk = null;
} }
$result = ['fields' => $fields, 'type' => $type, 'bind' => $bind, 'pk' => $pk]; $this->info[$guid] = ['fields' => $fields, 'type' => $type, 'bind' => $bind, 'pk' => $pk];
$_info[$guid] = $result;
} }
return $fetch ? $_info[$guid][$fetch] : $_info[$guid]; return $fetch ? $this->info[$guid][$fetch] : $this->info[$guid];
} }
/** /**