Re: Using transactions in MySQL + PHP



João Morais wrote:
How to use COMMIT/ROLLBACK is more of a SQL question and belongs in
comp.lang.mysql.

Sorry but I dont agree.. the question is not how to use commit/
rollback in a general way, but with PHP. If I only used MySQL i
wouldnt have this problem at all.


Commit/Rollback are SQL commands, not PHP. If you need to learn more about how to use them, you need a SQL newsgroup. Their use is not dependent on PHP or any other language. They work the same from the MySQL command line, for instance.

mysql_query(), etc. are PHP functions, and are appropriate for this group.

I don't think it's a good idea to use die() - is that what you want your
client to see?

I just used die as an example of abort/report failure, I wont use this
in my final script.

Additionally, I'm not sure die() will roll back your transaction.

For what I understood, (and I may be wrong), the data will only be
saved if COMMIT is done. So if one of the first 3 queries fail, no
COMMIT will be done, then no data will be saved.

Same occurs if first 3 queries are made with success, and the last one
fails.


As I said - I'm not sure on that. You need to check the MySQL newsgroups as to what MySQL does in this case.


There are other things you will need to consider with COMMIT and
ROLLBACK.

What things?


See comp.databases.mysql.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)
  • Re: I am totally stumped..with this on..LOAD_FILE Mysql+PHP= FSCK!!
    ... What I am trying to do is to upload files and stuff them in a mysql database. ... I copied the temporary file to somewhere else, and then handed it to MySQL..THAT WORKED.. ... Is there a way to force a close on the file..maybe that's the problem Mysql is opening a file that is not flushed to disk maybe? ... I gew the feeling its maintaining its own picture of file objects, and doesn't actually flush to the disk unless you do a copy or close php.. ...
    (comp.lang.php)
  • Re: com_dotnet
    ... And if MySQL isn't installed, the DLL won't load and phpinfowill show MySQL support isn't enabled. ... The MySQL interface is NOT compiled into PHP on the distributed Windows binaries - or you'd never be able to run PHP unless you had MySQL installed. ... *SOME* extensions are protocols, some are functional resources, and some are just type libraries. ... If you're going to compile the extension into PHP itself, the libraries must be available at compile time, and when you run PHP, or PHP won't load. ...
    (comp.lang.php)
  • Re Re: PHP 5.2.4 <= various mysql functions safemode & open_basedir bypass
    ... > various mysql functions safemode & open_basedir bypass ... PHP is currently very used because it's easy to use. ... Apache has directory restrictions. ... # if the mysql user has perms, ...
    (Bugtraq)
  • Re: [PHP] Select record by ID
    ... But I dont want to be a php copy/paste newb who has no clue ... Bad Guys know that you are probably using that user_id in an SQL ... The mysql_real_escape_string() part is a function provided by MySQL ... mysql_real_escape_stringtakes the 'Kevin O'Brien' and converts it ...
    (php.general)