mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-08 15:42:48 +08:00
Model类的allowField方法支持传入true 表示只允许写入数据表字段
This commit is contained in:
@@ -556,6 +556,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
|
|
||||||
// 检测字段
|
// 检测字段
|
||||||
if (!empty($this->field)) {
|
if (!empty($this->field)) {
|
||||||
|
if (true === $this->field) {
|
||||||
|
$this->field = $this->db->getTableInfo('', 'fields');
|
||||||
|
}
|
||||||
foreach ($this->data as $key => $val) {
|
foreach ($this->data as $key => $val) {
|
||||||
if (!in_array($key, $this->field)) {
|
if (!in_array($key, $this->field)) {
|
||||||
unset($this->data[$key]);
|
unset($this->data[$key]);
|
||||||
@@ -673,7 +676,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
|
|||||||
/**
|
/**
|
||||||
* 设置允许写入的字段
|
* 设置允许写入的字段
|
||||||
* @access public
|
* @access public
|
||||||
* @param bool $update
|
* @param bool|array $field 允许写入的字段 如果为true只允许写入数据表字段
|
||||||
* @return $this
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function allowField($field)
|
public function allowField($field)
|
||||||
|
|||||||
Reference in New Issue
Block a user