改进模型类的checkallowfield方法

This commit is contained in:
thinkphp
2017-07-05 11:35:06 +08:00
parent 5c733a7743
commit e428c43ec5

View File

@@ -1094,19 +1094,16 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
protected function checkAllowField($auto = [])
{
if (!empty($this->field)) {
if (!empty($this->origin)) {
$this->field = array_keys($this->origin);
$field = $this->field;
} elseif (true === $this->field) {
$this->field = $this->getQuery()->getTableInfo('', 'fields');
$field = $this->field;
} else {
$field = array_merge($this->field, $auto);
}
if (true === $this->field) {
$this->field = $this->getQuery()->getTableInfo('', 'fields');
$field = $this->field;
} elseif (!empty($this->field)) {
$field = array_merge($this->field, $auto);
} else {
$field = [];
}
return $field;
}