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:

  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. 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.

HTH,

        Benjamin.

-- 
[EMAIL PROTECTED]

---------------------------------------------------------------------
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