我在mysqli_multi_query
的帮助下解雇了以下查询。哪个正在执行但没有返回任何值。它返回空白。问题是mysqli_multi_query
有什么问题,或者在codeigniter中触发多个查询是否有任何替代方法。
$sql="LOCK TABLE xp_subunit WRITE; ";
$sql .= "SELECT @myLeft := ".$_GET['lft'].", @myRight := ".$_GET['rgt'].", @myWidth := ".$_GET['lft']." - lft + 1
FROM xp_subunit
WHERE id =".$_GET['id']."; ";
$sql .= "DELETE FROM xp_subunit WHERE lft BETWEEN @myLeft AND @myRight; ";
$sql .= "UPDATE xp_subunit SET rgt = rgt - @myWidth WHERE rgt > @myRight; ";
$sql .= "UPDATE xp_subunit SET lft = lft - @myWidth WHERE lft > @myRight; ";
$sql.="UNLOCK TABLES;";
//echo $sql;
$query = $this->db->mysqli_multi_query($sql);
答案 0 :(得分:1)
试试以下示例。
<?php
$mysqli = new mysqli("localhost", "my_user", "my_password", "world");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT CURRENT_USER();";
$query .= "SELECT Name FROM City ORDER BY ID LIMIT 20, 5";
/* execute multi query */
$mysqli->multi_query($query);
?>
我认为这可以帮助您获得解决方案。