I try to lock the whole table.
Using the following codes: Issues: the if statement never print true, If I change to some other select statement with $sql, it works
$link = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_NAME);
$sql = "lock table tableA write";
if($stmt = mysqli_prepare($link, $sql))
echo "true";
*Also for testing, there are no other codes in my php other these. Also I checked the user, has
GRANT SELECT, INSERT, UPDATE, LOCK TABLES ON *.* TO 'user'@'localhost'
I can not figure it out... and I am new to mysql with PHP as well.. Any help would be greatly appreciated
Edit: after added mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
it shows the error message:
PHP Fatal error: Uncaught mysqli_sql_exception: This command is not supported in the prepared statement protocol yet in /var/www/html/x.php:27 Stack trace: #0 /var/www/html/x.php(27): mysqli_prepare(Object(mysqli), 'lock table tableA...') #1 {main} thrown in /var/www/html/x.php on line 27
I found the solution.. you can call it directly with mysqli_query(..) since mysqli_prepare does not support locking.
if(mysqli_query($link,$sql)){
echo "true";
}