mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-01 20:52:48 +08:00
改进Model类的field属性定义 varchar类型的属性可以不用定义类型,例如:
protected $field = [ 'id'=>'int','name','email','create_time'=>'int', ];
This commit is contained in:
@@ -154,12 +154,19 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
||||
|
||||
if (!empty($this->field)) {
|
||||
if (true === $this->field) {
|
||||
$this->field = $this->db()->getTableInfo('', 'type');
|
||||
}
|
||||
if (is_array($this->field) && key($this->field) !== 0) {
|
||||
$query->setFieldType($this->field);
|
||||
$this->field = array_keys($this->field);
|
||||
$type = $this->db()->getTableInfo('', 'type');
|
||||
} else {
|
||||
$type = [];
|
||||
foreach ((array) $this->field as $key => $val) {
|
||||
if (is_int($key)) {
|
||||
$key = $val;
|
||||
$val = 'varchar';
|
||||
}
|
||||
$type[$key] = $val;
|
||||
}
|
||||
}
|
||||
$query->setFieldType($type);
|
||||
$this->field = array_keys($type);
|
||||
$query->allowField($this->field);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user