eg: as code of Documentation
try {
// 开始一个事务
$connection->begin();
// 执行一些操作
$connection->execute("DELETE `robots` WHERE `id` = 101");
$connection->execute("DELETE `robots` WHERE `id` = 102");
$connection->execute("DELETE `robots` WHERE `id` = 103");
$connection->execute("CREATE TABLE SQL");
$connection->execute("");
// 提交操作,如果一切正常
$connection->commit();
} catch (Exception $e) { // 如果发现异常,回滚操作 $connection->rollback(); }
return SQLSTATE[HY000]: General error: trying to execute an empty query;
The sql of creater table have been success。no rollback.