简体   繁体   中英

MySQLi multi_query wont return more than 1 results

When the result is limited to 1, everything works great.

However, when I have more than 1 results...it doesn't return anything.

$output = $conn->multi_query("CALL `test_discount`('022979', 1101, 1, 'W', 100, @out); SELECT @out AS `discount`;");

if ($output == true){
    while($conn->next_result()){
        $result = $conn->store_result();
            while ($row = $result->fetch_assoc()){
                print_r($row);
                break;
            }                   
    if($conn->more_results() == false) { break; };
    }
}

Am guessing I am doing something wrong?

If SQL above makes any sense , then I would suggest to fetch the data returned by the procedure first, and then select that stray @out variable.

$sql = "CALL `test_discount`('022979', 1101, 1, 'W', 100, @out)";
$res = $conn->multi_query($sql);
do {
    if ($res = $mysqli->store_result()) {
        foreach ($res as $row) {
            print_r($row);
        }
    }
} while ($mysqli->more_results() && $mysqli->next_result());

$out = $conn->query("SELECT @out")->fetch_row[0];

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