mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Connection类的transaction方法支持返回值
This commit is contained in:
@@ -426,18 +426,20 @@ abstract class Connection
|
|||||||
* 执行数据库事务
|
* 执行数据库事务
|
||||||
* @access public
|
* @access public
|
||||||
* @param callable $callback 数据操作方法回调
|
* @param callable $callback 数据操作方法回调
|
||||||
* @return void
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
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, []);
|
$result = call_user_func_array($callback, []);
|
||||||
}
|
}
|
||||||
$this->commit();
|
$this->commit();
|
||||||
|
return $result;
|
||||||
} catch (\PDOException $e) {
|
} catch (\PDOException $e) {
|
||||||
$this->rollback();
|
$this->rollback();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user