Re: mysql lock
| From: | Adam Voigt | Date: | Fri, 27 Jun 2003 15:49:33 +0000 |
| Subject: | Re: mysql lock | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-153155@lists.php.net to get a copy of this message | ||
Yes you seem to have it figured out, just do the lock in
a normal mysql_query, following the MySQL manual for syntax,
and you can release a lock whenever you want, but the
rule is the sooner the better, since if more then one page
or query tries to do a write, while you have it locked it
has to wait and wait until your lock is released.
On Fri, 2003-06-27 at 11:45, anders thoresson wrote:
> Hi,
>
> I've never used a lock on a MySQL table so far, but need one now. Two
> questions:
>
> 1. Do I set the lock by a normal query, but in the form of "LOCK TABLE
> <tablename> WRITE", instead of "SELECT * FROM <tablename> WHERE x =
> 1"?
>
> 2. Can I set the lock in one query, then perform multiple other queries on
> the table, in between which I do some PHP work, and then release the lock
> several queries and lines of PHP code later?
>
> In general, when is it wise to use a lock, and when is it uneeded?
>
> --
> anders thoresson
--
Adam Voigt (adam@cryptocomm.com)
Linux/Unix Network Administrator
The Cryptocomm Group