From fc432d5f5dce0daabf50a668276c4be68f3ef64d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Fri, 5 May 2017 17:01:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Model=E7=B1=BB=E7=9A=84save?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Model.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/library/think/Model.php b/library/think/Model.php index 8553fec6..e92a9344 100644 --- a/library/think/Model.php +++ b/library/think/Model.php @@ -995,7 +995,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } // 模型更新 - $result = $this->db()->where($where)->update($data); + $result = $this->getQuery()->where($where)->update($data); // 关联更新 if (isset($relation)) { @@ -1022,11 +1022,11 @@ abstract class Model implements \JsonSerializable, \ArrayAccess return false; } - $result = $this->db()->insert($this->data); + $result = $this->getQuery()->insert($this->data); // 获取自动增长主键 if ($result && is_string($pk) && (!isset($this->data[$pk]) || '' == $this->data[$pk])) { - $insertId = $this->db()->getLastInsID($sequence); + $insertId = $this->getQuery()->getLastInsID($sequence); if ($insertId) { $this->data[$pk] = $insertId; } @@ -1114,7 +1114,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } $result = []; - $db = $this->db(); + $db = $this->getQuery(); $db->startTrans(); try { $pk = $this->getPk(); @@ -1228,7 +1228,7 @@ abstract class Model implements \JsonSerializable, \ArrayAccess } // 删除当前模型数据 - $result = $this->db()->where($where)->delete(); + $result = $this->getQuery()->where($where)->delete(); // 关联删除 if (!empty($this->relationWrite)) {