tags:

views:

54

answers:

1

I need to concatenate a file id before insert, thus want to lock a reference table for read and write. How can I do that?

Just locking the table for read, still allows select from that table

$SqlLock2 = "LOCK TABLES TableName t1 READ"; mysql_query($SqlLock2) or die(mysql_error());

// Select something from TableName

$SqlUnlock = "UNLOCK TABLES"; mysql_query($SqlUnlock) or die(mysql_error());

+1  A: 

READ locks are always shared locks; you must lock it for WRITE for an exclusive access (even if you only read it afterwards)

Aaron Digulla
Thank you for the response.
Natkeeran