We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

about transaction no rollback "Transactions and Nested Transactions"

eg: as code of Documentation

try {

// 开始一个事务

// 执行一些操作
$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"); 

// 提交操作,如果一切正常

} 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.

edited Mar '16

What is your db backend and engine? MyISAM for eg. doesn't support transactions...

Also, create and alter table transaction support is rather limited, see this answer: http://stackoverflow.com/questions/4692690/is-it-possible-to-roll-back-create-table-and-alter-table-statements-in-major-sql

MySQL - no; DDL causes an implicit commit

edited Mar '16

think linux MYSQL , mysql engine is INNOdb. but autocommit value is ON.

Autocommit doesn't matter, because you're initiating a transaction explicitly.

But as mentioned in the SO thread, table creates are commitied automatically, you don't have control over that command. Remove $connection->execute("CREATE TABLE SQL"); and you'll be able to rollback the rest.

thinks. I know what you mean . but I need CREATE TABLE SQL to rollback.