mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
改进Model类的getDbFields方法
This commit is contained in:
@@ -231,7 +231,7 @@ class Model {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 分析表达式
|
// 分析表达式
|
||||||
$options = $this->_parseOptions();dump($this->fields);
|
$options = $this->_parseOptions();
|
||||||
// 数据处理
|
// 数据处理
|
||||||
$data = $this->_facade($data);
|
$data = $this->_facade($data);
|
||||||
if(false === $this->_before_insert($data,$options)) {
|
if(false === $this->_before_insert($data,$options)) {
|
||||||
@@ -934,24 +934,23 @@ class Model {
|
|||||||
$fields = Cache::get(md5($this->getTableName()));
|
$fields = Cache::get(md5($this->getTableName()));
|
||||||
if(!$fields) {
|
if(!$fields) {
|
||||||
$fields = $this->db->getFields($this->getTableName());
|
$fields = $this->db->getFields($this->getTableName());
|
||||||
|
$this->fields = array_keys($fields);
|
||||||
foreach ($fields as $key=>$val){
|
foreach ($fields as $key=>$val){
|
||||||
// 记录字段类型
|
// 记录字段类型
|
||||||
$type[$key] = $val['type'];
|
$type[$key] = $val['type'];
|
||||||
if($val['primary']) {
|
if($val['primary']) {
|
||||||
$fields['_pk'] = $key;
|
$this->fields['_pk'] = $key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 记录字段类型信息
|
// 记录字段类型信息
|
||||||
$fields['_type'] = $type;
|
$this->fields['_type'] = $type;
|
||||||
Cache::set(md5($this->trueTableName),$fields);
|
Cache::set(md5($this->trueTableName),$this->fields);
|
||||||
}
|
return array_keys($fields);
|
||||||
if($fields) {
|
}else{
|
||||||
$this->fields = array_keys($fields);
|
$this->fields = $fields;
|
||||||
$this->fields['_pk'] = $fields['_pk'];
|
unset($fields['_pk'],$fields['_type']);
|
||||||
$this->fields['_type'] = $fields['_type'];
|
|
||||||
return array_keys($fields);
|
return array_keys($fields);
|
||||||
}
|
}
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user