note 97499 deleted from mysqli.autocommit by danbrown

From: Date: Fri, 23 Apr 2010 12:32:52 +0000
Subject: note 97499 deleted from mysqli.autocommit by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-168551@lists.php.net to get a copy of this message
Note Submitter: Matt ---- A note for anyone concerned about the post by Glen on Mar 11 2007. I've tested mysqli transactions forcing a runtime error before the commit and the issue he describes (future requests hanging until restarting apache). In my testing I redeclared a function before the commit to cause a runtime fatal error. When the error was hit, a rollback was successfully performed automatically. The changes were never committed to the database and did not hang forever in a pending state as he seems to have experienced. Try it for yourself, example: <?php $mysqli->autocommit( false ); $mysqli->query( "INSERT INTO table SET col = val" ); $mysqli->query( "INSERT INTO table SET col = val" ); $mysqli->query( "INSERT INTO table SET col = val" ); echo 'Made it this far.' // Force a runtime error. function a(){} function a(){} echo 'Even further.' $mysqli->commit(); ?> This will output 'Made it this far.' and then error out and the changes will automatically be rolled back by MySQL. If you run it again without the function a(){}, it runs fine and the changes commit correctly. This issue seems to be resolved based on my testing of Apache 2.0.63 / PHP 5.3.2 / MySQL 5.1.44.

« previous php.notes (#168551) next »