改进Model类的save方法

This commit is contained in:
thinkphp
2016-10-08 14:45:14 +08:00
parent 8f59235a0a
commit 01c3d34940

View File

@@ -680,7 +680,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
$where = $this->updateWhere; $where = $this->updateWhere;
} }
if (!empty($where)) {
$pk = $this->getPk(); $pk = $this->getPk();
if (is_string($pk) && isset($data[$pk])) { if (is_string($pk) && isset($data[$pk])) {
if (!isset($where[$pk])) { if (!isset($where[$pk])) {
@@ -689,7 +688,6 @@ abstract class Model implements \JsonSerializable, \ArrayAccess
} }
unset($data[$pk]); unset($data[$pk]);
} }
}
$result = $this->db()->where($where)->update($data); $result = $this->db()->where($where)->update($data);
// 清空change // 清空change