相关疑难解决方法(0)

PHP:«命令不同步»如果我调用结果存储过程后再次mysqli :: query()

我的数据库中有一个存储过程,它返回表中的所有记录:

CREATE PROCEDURE showAll()
BEGIN
    SELECT * FROM myTable;
END
Run Code Online (Sandbox Code Playgroud)

SP的工作方式与预期一致.但是,如果我在php脚本中调用它,然后我尝试再次查询数据库,它总是失败:

// $mysqli is a db connection

// first query:

if (!$t = $mysqli->query("call showAll()"))
    die('Error in the 1st query');

while ($r = $t->fetch_row()) {
    echo $r[0] . "<br>"; // this is ok
}

$t->free(); // EDIT (this doesn't help anyway)

// second query (does the same thing):

if (!$t = $mysqli->query("SELECT * from myTable"))
    die('Error in the 2nd query'); // I always get this error

while ($r = $t->fetch_row()) …
Run Code Online (Sandbox Code Playgroud)

php mysqli stored-procedures

6
推荐指数
1
解决办法
2730
查看次数

标签 统计

mysqli ×1

php ×1

stored-procedures ×1