From 8cca5524a7dc56de40a7c6f4e80ef6f28ac36632 Mon Sep 17 00:00:00 2001 From: thinkphp Date: Sat, 23 Apr 2016 18:31:27 +0800 Subject: [PATCH] =?UTF-8?q?Connection=E7=B1=BB=E7=9A=84transaction?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=94=AF=E6=8C=81=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/Connection.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/library/think/db/Connection.php b/library/think/db/Connection.php index adfc1635..11ccc99d 100644 --- a/library/think/db/Connection.php +++ b/library/think/db/Connection.php @@ -426,18 +426,20 @@ abstract class Connection * 执行数据库事务 * @access public * @param callable $callback 数据操作方法回调 - * @return void + * @return mixed */ public function transaction($callback) { $this->startTrans(); try { if (is_callable($callback)) { - call_user_func_array($callback, []); + $result = call_user_func_array($callback, []); } $this->commit(); + return $result; } catch (\PDOException $e) { $this->rollback(); + return false; } }