NoComment Posted June 27, 2007 Share Posted June 27, 2007 Hi there! I'm currently looking for a way to implement mutexes in PHP/MySQL. I wasn't sure if it belongs into the PHP forum or rather into the MySQL forum. So I apologize if it's in the wrong forum. Imagine PHP script #1 tries to access a MySQL database and reads data from a table. At the same time PHP script #2 is executed, which tries to delete the very data script #1 is currently trying to read. This is especially problematic if script #1 has to read from the database multiple times, process the read information, read from the database again, etc, while the 2nd script is deleting this data. Is there a way to prevent that--so that PHP script #2 waits till PHP script #1 has done all its work and THEN deletes the table? Of course, the above mentioned situation is only an example, and I don't need a fix for THIS specific example, but I need to find a more generic way to implement mutexes/semaphores. Does anybody have an idea on how to do that? Thank you in advance! Quote Link to comment https://forums.phpfreaks.com/topic/57473-semaphoresmutexes/ Share on other sites More sharing options...
Wildbug Posted June 27, 2007 Share Posted June 27, 2007 Is this something that [uN]LOCK TABLES will do sufficiently for you? LOCK TABLES and UNLOCK TABLES Syntax See also 1.9.5.3. Transactions and Atomic Operations. Quote Link to comment https://forums.phpfreaks.com/topic/57473-semaphoresmutexes/#findComment-284429 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.