SELECT FOR UPDATE

From: Date: Mon, 02 Jun 2008 15:15:42 +0000
Subject: SELECT FOR UPDATE
Groups: php.db 
Request: Send a blank email to php-db+get-45025@lists.php.net to get a copy of this message
Hi all. Which is more efficient in order to use SELECT FOR UPDATE? %> SELECT * FROM table WHERE (table_id = 32) LIMIT 1 FOR UPDATE; %> UPDATE table SET field_name = 'Pizza' WHERE (table_id = 32) LIMIT 1; OR %> SELECT field_name FROM table WHERE (table_id = 32) LIMIT 1 FOR UPDATE; %> UPDATE table SET field_name = 'Pizza' WHERE (table_id = 32) LIMIT 1; Note: the 2nd query in each is the same. Is there any difference in using * and specifying the actual field you want to update? It seems like there would be very little difference because this is causing a row-lock - all the data in that row is not-updatable anyway. I'm adding transactions and row-locking into my application. If I can just use the first method (because it's easier to specify '*' instead of every column I want to update), then I'd like to. Any thoughts are welcome! Thanks in advance, ~Philip "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

« previous php.db (#45025) next »