Benjamin Pflugmann wrote:

Hello.

On Sat 2002-12-07 at 14:15:59 -0800, [EMAIL PROTECTED] wrote:

I would like to lock a specific record in a MySQL table so that no other user can update it while another user is is update the record via the user interface. Can someone please tell me the easiest way to do this?

Depends on the table handler. With MYISAM, you can only lock the whole
table (via LOCK TABLE). So you would rather refrain from that way of
assuring no change has made.

With InnoDB you can lock a row by selecting it:

Ben, thanks so much for your respoonse.

How do I switch from MYISAM to InnoDB? Are there any negative implication in swithing?

 SELECT *
 FROM your_table
 WHERE <some-condition-for-the-row-in-question>
 FOR UPDATE

will lock that row for you. Of course, only as long as you keept the
connection open.


But usually it is a bad idea to implement application level locks by
using database locks.

I agree but it's only for in the office use on a small LAN so we could just walk over to the offending person computer and get them out -- atleast until I get some sort of timeout mechanism in place.

What if I leave my computer? You have to
implement some kind of timeout. And so on. Better to implement
conflict handling correctly from the start.

Any ideas here are of course welcomed. :-)


HTH,

Benjamin.




---------------------------------------------------------------------
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to