I am trying to use mysqli to insert data, and there is a weird behavior. For example, when I first used it $mysqli->autocommit(FALSE);and spent a few minutes starting my PHP and waiting for the request, it will store the database until $mysqli->commit();, so I cannot perform any other database operation. When I check the status in phpmyadmin, it shows that the next SQL query has a status Waiting for table metalock, how can I fix it? Thanks
function putLog($query){
global $mysqli,$ip,$browser,$dateLog,$isQuerySuccess;
$isQuerySuccess = $mysqli->query("INSERT INTO DPS_Log_$dateLog (PageID,FunctionID,ActionID,UserID,UserIP,UserInfo,LogType,Remark,LogTime) VALUES (15,20,25,25,'$ip','$browser',1,'$query',NOW())") ? true : false;
}
$mysqli = new mysqli(DATABASEIP, DBUSER, DBPWD, DATABASE,PORT);
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$mysqli->autocommit(FALSE);
$isQuerySuccess = true;
putLog ("Fail to delete: $folderPath.$item");
$isQuerySuccess ? $mysqli->commit() : $mysqli->rollback();
$mysqli->close();
: , , , . , , , . , ( > 30 ), ( metalock), , ?
$sql = "
CREATE TABLE IF NOT EXISTS `$logTableName` (
`ID` int(11) NOT NULL AUTO_INCREMENT,
`PageID` int(2),
`FunctionID` int(2),
`ActionID` int(3) NOT NULL,
`UserID` int(5) NOT NULL,
`UserIP` varchar(15) COLLATE utf8_unicode_ci NOT NULL,
`UserInfo` text COLLATE utf8_unicode_ci NOT NULL,
`LogType` int(1) NOT NULL DEFAULT '1',
`Remark` text COLLATE utf8_unicode_ci NOT NULL,
`LogTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`ID`)
)ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
";
$this -> databaseHelper -> common_query($sql);