mysql rollback with php

Discussions of secure PHP coding. Security in software is important, so don't be afraid to ask. And when answering: be anal. Nitpick. No security vulnerability is too small.

Moderator: General Moderators

Post Reply
nga
Forum Commoner
Posts: 46
Joined: Mon Aug 17, 2009 3:05 am

mysql rollback with php

Post 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?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: mysql rollback with php

Post 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.
(#10850)
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: mysql rollback with php

Post 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
Post Reply