简体   繁体   English

MySQLi multi_query不会返回超过1个结果

[英]MySQLi multi_query wont return more than 1 results

When the result is limited to 1, everything works great. 当结果限制为1时,一切正常。

However, when I have more than 1 results...it doesn't return anything. 但是,当我有1个以上的结果时...什么也不会返回。

$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有意义 ,那么我建议先获取该过程返回的数据,然后选择该杂散@out变量。

$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];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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