MySQL - Locking the table and seeing


How Can I lock the table, see that the table is locked.

$mysqlibag->query(“LOCK TABLES user WRITE;”);

$sonuc1 = $mysqlibag->query(“SHOW OPEN TABLES”);
$sonuc =$sonuc1->fetch_array();

Best Regards

If you just print_r the “in_use”, you’ll just get a bunch of 0,1 and 2’s

1 and 2 are locked tables.

If you print_r the entire array, you should see the table names also.

[php] $mysqlibag->query(“LOCK TABLES user WRITE;”);
$sonuc1 = $mysqlibag->query(“SHOW OPEN TABLES”);
$sonuc =$sonuc1->fetch_array();

Thank you for your answer,

I saw the result “0” always.


Array ( [0] => performance_schema [Database] => performance_schema [1] => events_waits_summary_by_user_by_event_name [Table] => events_waits_summary_by_user_by_event_name [2] => 0 [In_use] => 0 [3] => 0 [Name_locked] => 0 ) 

It’s locked per client session.

If you want to do a table lock and see it locked, I think you need to do something like this…

[php]$mysqli->multi_query(“LOCK TABLES user WRITE;SHOW OPEN TABLES”)[/php]

Thank you for your help, but I can’t run it.
$sonuc1 = $mysqlibag->multi_query(“LOCK TABLES user WRITE;SHOW OPEN TABLES”)
$sonuc =$sonuc1->fetch_array();

Thank you,
Problem ok

[php]$sq1a = mysql_query(“LOCK TABLE tablo1 READ, tablo2 READ”);
$sql1 = mysql_query(“show open tables where In_use > 0”);
while($rw = mysql_fetch_array($sql1)){
echo “Locks : “.$rw[1].” - “.$rw[2].””;

Glad you got it working, I was going to mock up an example! Now I don’t have too.

Sponsor our Newsletter | Privacy Policy | Terms of Service