简体   繁体   中英

mysqli_multi_query not returning any value

I fired the following query with the help of mysqli_multi_query . Which is executing properly but not returning any value. It returning blank. Whats wrong with the mysqli_multi_query or is there any alternative for this for firing multiple queries in 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);

Just Try with the following Example.,

<?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);
?>

I think this may help you to get the solution.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM