Data lock on MySQL & PHP

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
ptshaft
Forum Newbie
Posts: 2
Joined: Wed Jul 30, 2003 6:14 am
Location: Portugal

Data lock on MySQL & PHP

Post by ptshaft »

I'm writing a dense project using MySQL as database engine, and PHP as script language.

Sometimes, I need what I think is called data-lock, for example, row-lock, or table-lock. Is there any easy way of doing it?
User avatar
Stoker
Forum Regular
Posts: 782
Joined: Thu Jan 23, 2003 9:45 pm
Location: SWNY
Contact:

Post by Stoker »

Mysql 3.23 (not sure about 4.x) does not have row level locks, only table..

LOCK TABLES mytable [READ|WRITE];
bla bla
UNLOCK TABLES;

READ allows read and prevents write, WRITE locks completely.. read the mysql manual section 6.7.3
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Moved to Databases.

Mac
kcomer
Forum Contributor
Posts: 108
Joined: Tue Aug 27, 2002 8:50 am

Post by kcomer »

I believe InnoDB has row level locking, but MyIASM only has table level locking. So, looks liek you need InnoDB tables. I have never tried this so can't say for sure how it works.

Keith
ptshaft
Forum Newbie
Posts: 2
Joined: Wed Jul 30, 2003 6:14 am
Location: Portugal

Post by ptshaft »

That was what I was afraid of, cause that's what i thought, default MySQL tables only allow table-level lock. I knew InnoDB allowed both row and table level lock, I just didn't want to jump into InnoDB tables. Looks like I have no other choice!

Tks.
Post Reply