Jump to content

MySQL PHP Transactions and table locking


random1

Recommended Posts

<?php

// Start transaction
mysql_query("BEGIN");

// do lots of SQL'y stuff here...

// Commit transaction.
mysql_query("COMMIT");

?>

 

Locking tables is not a good idea, and in fact MySQL deals with it's own version of row/table locking so that you don't have to bother with it.

Because you're using a transaction until the item is commited they're working with a virtual copy of the table, i.e. what they see while inside the transaction doesn't actually represent what is in the current table layout.

 

Thus, you don't need to worry about it. MySQL will deal with all the thinking for you.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.