email:
password:

Register
Forum Stats
Total Threads:
4104

Total Posts:
10050

Top Posters
Michael 2304
Dylan 1805
onemiamibum 710
JennyJM 645
nicole 484
Francisco 301
m1nr 262
Marty 256
dav 199
kyle 176
Fla 155
ultron 146
henryjoebob 142
Xandy 133
manic 127
Jess 124
Sarah 123
Cindy 123
Adam 106
Jessica 104
Random Faqqing
Why Should I Register For Idiotechnica.com?
The question is, why shouldn't you register. Click Here To Find Out.
firefox_logo
idiotechnica.com uses CSS3 and is optimized for viewing in Firefox versions 3+

Posts: Computers and Technology / MySQL Error: Table was not locked with LOCK TABLES

share this thread on facebook

Michael Post Author Photo: Michael
MySQL Error: Table was not locked with LOCK TABLES
11/11/09 08:53 PM

live and learn

Two reasons for this unwelcome scenario which was causing some transactions to be denied:

from mysql documentation for table locks:
A session that requires locks must acquire all the locks that it needs in a single LOCK TABLES statement. While the locks thus obtained are held, the session can access only the locked tables. For example, in the following sequence of statements, an error occurs for the attempt to access t2 because it was not locked in the LOCK TABLES statement:

from php documentation for mysql_connect:
new_link

If a second call is made to mysql_connect() with the same arguments, no new link will be established, but instead, the link identifier of the already opened link will be returned. The new_link parameter modifies this behavior and makes mysql_connect() always open a new link, even if mysql_connect() was called before with the same parameters. In SQL safe mode, this parameter is ignored.

in otherwords. if you have 2 database objects running and expect to use the second to access tables if the first has locked other tables, use the new_link = true variable for mysql_connect or the second object will be considered the same session as the first and be subject to the same table locks.
Offline
Post ID: 3491

Dylan Post Author Photo: Dylan
11/11/09 08:55 PM

Thanks, Goldilocks. Give me something to work on.
Offline
Post ID: 3492