改进Model类的save方法 修正Merge类的save方法支持 where参数更新

This commit is contained in:
thinkphp
2016-06-17 11:55:52 +08:00
parent f8d7bb61c8
commit dcc1f7b15e
2 changed files with 17 additions and 7 deletions

View File

@@ -586,7 +586,8 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
$result = $this->db()->where($where)->update($data);
// 清空change
$this->change = [];
// 更新回调
$this->trigger('after_update', $this);
} else {
@@ -613,16 +614,14 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
}
$result = $insertId;
}
// 标记为更新
$this->isUpdate = true;
// 新增回调
$this->trigger('after_insert', $this);
}
// 写入回调
$this->trigger('after_write', $this);
// 标记为更新
$this->isUpdate = true;
// 清空change
$this->change = [];
return $result;
}