From e5b42f95c531b898e24a238b03759ac585cec17f Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 30 Jan 2017 14:53:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9BQuery=E7=B1=BBafter=5Finsert?= =?UTF-8?q?=20after=5Fupdata=20after=5Fdelete=20before=5Fselect=20before?= =?UTF-8?q?=5Ffind=20=E5=9B=9E=E8=B0=83=E6=96=B9=E6=B3=95=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20=E7=BB=9F=E4=B8=80=E4=BC=A0=E5=85=A5$optio?= =?UTF-8?q?ns['data']?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Query.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/library/think/db/Query.php b/library/think/db/Query.php index 65e1b07f..8b222bab 100644 --- a/library/think/db/Query.php +++ b/library/think/db/Query.php @@ -2214,6 +2214,14 @@ class Query // 执行操作 $result = '' == $sql ? 0 : $this->execute($sql, $bind); if ($result) { + if (is_string($pk)) { + if (isset($where[$pk])) { + $data[$pk] = $where[$pk]; + } elseif (isset($key) && strpos($key, '|')) { + list($a, $val) = explode('|', $key); + $data[$pk] = $val; + } + } $options['data'] = $data; $this->trigger('after_update', $options); } @@ -2287,6 +2295,8 @@ class Query // 获取实际执行的SQL语句 return $this->connection->getRealSql($sql, $bind); } + + $options['data'] = $data; if ($resultSet = $this->trigger('before_select', $options)) { } else { // 执行查询操作 @@ -2408,7 +2418,7 @@ class Query // 获取实际执行的SQL语句 return $this->connection->getRealSql($sql, $bind); } - + $options['data'] = $data; // 事件回调 if ($result = $this->trigger('before_find', $options)) { } else { @@ -2625,6 +2635,7 @@ class Query // 执行操作 $result = $this->execute($sql, $bind); if ($result) { + $options['data'] = $data; $this->trigger('after_delete', $options); } return $result;