Model类的save方法传入更新条件的时候 标识为更新操作

This commit is contained in:
thinkphp
2016-04-08 17:16:15 +08:00
parent 5af38b9bd0
commit 96c7d2c25a

View File

@@ -59,10 +59,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
// 字段类型或者格式转换
protected $type = [];
// 当前执行的关联类型
private $relation;
// 是否为更新数据
protected $isUpdate = false;
// 当前执行的关联类型
private $relation;
/**
* 初始化过的模型.
@@ -108,9 +108,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
* @return void
*/
protected static function init()
{
}
{}
// JsonSerializable
public function jsonSerialize()
@@ -331,6 +329,9 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
foreach ($data as $key => $value) {
$this->__set($key, $value);
}
if (!empty($where)) {
$this->isUpdate = true;
}
}
// 数据自动验证
if (!$this->validateData()) {