Hi all.
I'm currently working on a project that's in its beta stage. Due to
time restraints, we were unable to build in transactions from the
beginning. Well, we're getting to the point where we can now put in
transactions. Basically, I'm curious to find out your opinion on the
best way to accomplish this.
Currently, my thoughts for doing this are:
<?php
function someFunctionThatNeedsTransactions ()
{
$this->db->begin(); // Start transaction
$this->db->query("SELECT..."); // Run my queries here
$this->db->query("UPDATE...");
// Do some PHP logic here
$this->db->query("SELECT..."); // Run more queries
$this->db->query("INSERT...");
$this->db->commit(); // Commit transaction
}
?>
If there was a failure in one of the queries, that would be caught in
the database class ('db' instance) and <?php $this->rollback(); ?>
would be called. Note that all the tables are InnoDB and the above
code/functionality works.
Ideally, I would have liked to use stored procedures, but that
decision was not mine. So are there any complications I'm potentially
missing? Any other thoughts on the direction to go at this point?
Thanks in advance,
~Philip
PS... No, I didn't have too much coffee this morning, Robin. ;)
"Personally, most of my web applications do not have to factor 13.7
billion years of space drift in to the calculations, so PHP's rand
function has been great for me..." ~S. Johnson
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php