Page 1 of 1
mysql rollback with php
Posted: Tue Jan 05, 2010 9:38 pm
by nga
hi, I have a question: How can execute sevelral mysql queries all together or none at all when a query failed? I know mysql have rollback command for innoDB but how can i use it in php?
Re: mysql rollback with php
Posted: Tue Jan 05, 2010 10:45 pm
by Christopher
In PHP you simply submit SQL queries to the server. Any SQL commands, such as COMMIT and ROLLBACK, work the same as they do from the command line.
Re: mysql rollback with php
Posted: Wed Jan 06, 2010 12:34 am
by flying_circus
nga wrote:hi, I have a question: How can execute sevelral mysql queries all together or none at all when a query failed? I know mysql have rollback command for innoDB but how can i use it in php?
PHP supports mysql transactions. Just be sure to turn autocommit to false
http://us3.php.net/manual/en/mysqli.rollback.php