我正在尝试在下面的代码中使用 mysqli_multi_query 函数,但遇到此错误:
命令不同步;你现在不能运行这个命令
// add call stats to incoming nodes
$sql = "INSERT INTO `" . node_name_formatter($i_route) . "` ";
$sql .= " (`timeperiod`, ";
$sql .= " `exchange_id`, ";
$sql .= " `calls_in`) ";
$sql .= "VALUES ('" . date('Y-m-d H:i:s', $time) . "', ";
$sql .= " '$exchange_id', ";
$sql .= " '1') ";
$sql .= "ON DUPLICATE KEY UPDATE ";
$sql .= " `calls_in` = `calls_in`+1;";
// add call stats to outgoing nodes
$sql .= "INSERT INTO `" . node_name_formatter($o_route) . "` ";
$sql .= " (`timeperiod`, ";
$sql .= " `exchange_id`, ";
$sql .= " `calls_out`) ";
$sql .= "VALUES ('" . date('Y-m-d H:i:s', $time) . "', ";
$sql .= " '$exchange_id', ";
$sql .= " '1') ";
$sql .= "ON DUPLICATE KEY UPDATE ";
$sql .= " `calls_out` = `calls_out`+1";
// echo $sql . '<br><br>';
mysqli_multi_query($connection, $sql) or die(mysqli_error($connection));
我正在按照php 手册中的说明进行此查询。使用这个函数还是按照正常的 mysqli_query 方式执行 2 个单独的查询更好?