我的数据库中有一个存储过程,它返回表中的所有记录:
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)