mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 07:32:48 +08:00
模型的数据不受allowfield影响
This commit is contained in:
@@ -943,18 +943,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检测字段
|
|
||||||
if (!empty($this->field)) {
|
|
||||||
if (true === $this->field) {
|
|
||||||
$this->field = $this->getQuery()->getTableInfo('', 'fields');
|
|
||||||
}
|
|
||||||
foreach ($this->data as $key => $val) {
|
|
||||||
if (!in_array($key, $this->field)) {
|
|
||||||
unset($this->data[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 数据自动完成
|
// 数据自动完成
|
||||||
$this->autoCompleteData($this->auto);
|
$this->autoCompleteData($this->auto);
|
||||||
|
|
||||||
@@ -990,6 +978,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
$where = $this->updateWhere;
|
$where = $this->updateWhere;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测字段
|
||||||
|
$this->checkAllowField($data);
|
||||||
|
|
||||||
// 保留主键数据
|
// 保留主键数据
|
||||||
foreach ($this->data as $key => $val) {
|
foreach ($this->data as $key => $val) {
|
||||||
if ($this->isPk($key)) {
|
if ($this->isPk($key)) {
|
||||||
@@ -1033,6 +1024,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检测字段
|
||||||
|
$this->checkAllowField($this->data);
|
||||||
|
|
||||||
$result = $this->getQuery()->insert($this->data);
|
$result = $this->getQuery()->insert($this->data);
|
||||||
|
|
||||||
// 获取自动增长主键
|
// 获取自动增长主键
|
||||||
@@ -1066,6 +1060,20 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function checkAllowField(&$data)
|
||||||
|
{
|
||||||
|
if (!empty($this->field)) {
|
||||||
|
if (true === $this->field) {
|
||||||
|
$this->field = $this->getQuery()->getTableInfo('', 'fields');
|
||||||
|
}
|
||||||
|
foreach ($data as $key => $val) {
|
||||||
|
if (!in_array($key, $this->field)) {
|
||||||
|
unset($data[$key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected function autoRelationUpdate($relation)
|
protected function autoRelationUpdate($relation)
|
||||||
{
|
{
|
||||||
foreach ($relation as $name => $val) {
|
foreach ($relation as $name => $val) {
|
||||||
|
|||||||
Reference in New Issue
Block a user