改进getdbfields方法

This commit is contained in:
thinkphp
2015-11-23 12:21:55 +08:00
parent aeb7252705
commit bd930b397e

View File

@@ -881,9 +881,10 @@ class Model
unset($fields['_pk'], $fields['_type']); unset($fields['_pk'], $fields['_type']);
return $fields; return $fields;
} else { } else {
$fields = Cache::get(md5($this->getTableName())); $tableName = $this->getTableName();
$fields = Cache::get(md5($tableName));
if (!$fields) { if (!$fields) {
$fields = $this->db->getFields($this->getTableName()); $fields = $this->db->getFields($tableName);
$this->fields = array_keys($fields); $this->fields = array_keys($fields);
foreach ($fields as $key => $val) { foreach ($fields as $key => $val) {
// 记录字段类型 // 记录字段类型
@@ -905,7 +906,7 @@ class Model
} }
// 记录字段类型信息 // 记录字段类型信息
$this->fields['_type'] = $type; $this->fields['_type'] = $type;
Cache::set(md5($this->trueTableName), $this->fields); Cache::set(md5($tableName), $this->fields);
$fields = $this->fields; $fields = $this->fields;
} else { } else {
$this->fields = $fields; $this->fields = $fields;