修正Driver当写入空数据的问题

This commit is contained in:
thinkphp
2016-04-07 15:37:57 +08:00
parent 2a56e81fce
commit 0abae164e4
2 changed files with 14 additions and 8 deletions

View File

@@ -286,12 +286,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
if (false === $this->trigger('before_update', $this)) {
return false;
}
// 更新的时候检测字段更改
if (!empty($this->change)) {
foreach ($data as $key => $val) {
if (!in_array($key, $this->change) && !$this->isPk($key) && !isset($this->relation[$key])) {
unset($data[$key]);
}
// 去除没有更新的字段
foreach ($data as $key => $val) {
if (!in_array($key, $this->change) && !$this->isPk($key) && !isset($this->relation[$key])) {
unset($data[$key]);
}
}