改进Model类的save方法 修正不按主键查询的更新问题

This commit is contained in:
thinkphp
2016-09-20 17:16:27 +08:00
parent 35890dad5c
commit cbfa98341b

View File

@@ -667,6 +667,10 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
if (!empty($where)) {
$pk = $this->getPk();
if (is_string($pk) && isset($data[$pk])) {
if (!isset($where[$pk])) {
unset($where);
$where[$pk] = $data[$pk];
}
unset($data[$pk]);
}
}