ajoo Posted March 13, 2014 Share Posted March 13, 2014 Hi, I am using transactions on a piece of code whose structure is somewhat like this if ( condition ) { mysqli_autocommit($fcon, false); if ( condition ) { $query " "; if ( condition ) { $query " "; if ( condition ) { $make = makeTable(); // where this is a function which creates a table and uses a query like INSERT into ... to create an entry in a table if ( $make == true) { $query " "; if ( condition ) { $query " "; } else else and so on ending all else. The problem is that the function call to makeTable prevents the roll back beyond that point. Please can someone tell me if and how it would be possible to roll back all the way to the defined starting point at the very beginning of the code block. Thanks all for any help, comments, suggestions. Quote Link to comment Share on other sites More sharing options...
fenway Posted March 27, 2014 Share Posted March 27, 2014 Very difficult to tell what you're fererring to -- but I'm assuming that your PHP code isn't actually *making* a table -- DML vs DDL matters. Quote Link to comment Share on other sites More sharing options...
DavidAM Posted March 27, 2014 Share Posted March 27, 2014 If the makeTable() function is actually making a Table (i.e. CREATE TABLE), then it can NOT be rolled back. In fact ... The statements listed in this section (and any synonyms for them) implicitly end any transaction active in the current session, as if you had done a COMMIT before executing the statement. As of MySQL 5.5.3, most of these statements also cause an implicit commit after executing; for additional details, see the end of this section.(emphasis added -- see http://dev.mysql.com/doc/refman/5.7/en/implicit-commit.html) Why are you creating a table in the middle of a transaction. Either create the table before you start the transaction, or redesign your application and database so you don't have to create tables on the fly. (Personally, I highly recommend the second option). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.