This commit is contained in:
thinkphp
2016-04-10 14:35:11 +08:00
parent 42073f04f9
commit f97626f6a2

View File

@@ -372,15 +372,16 @@ abstract class Driver
* @param callable $callback 数据操作方法回调 * @param callable $callback 数据操作方法回调
* @return void * @return void
*/ */
public function transaction($callback){ public function transaction($callback)
{
$this->startTrans(); $this->startTrans();
try { try {
if (is_callable($callback)) { if (is_callable($callback)) {
call_user_func_array($callback, [$sql, $runtime, $explain]); call_user_func_array($callback, []);
} }
$this->commit(); $this->commit();
}catch (\PDOException $e) { } catch (\PDOException $e) {
$this->rollback() $this->rollback();
} }
} }