我正在尝试在 PHP 中循环通过准备好的语句调用的存储过程。希望这不是不可能的。这是我的 PHP 代码:
$database = new mysqli($server, $user, $pass, $db);
$stmt = $database->prepare("CALL thisShouldReturnEightResultSets (?)");
$stmt->bind_param("i", $id);
$stmt->execute();
do {
if ($res = $stmt->bind_result($myvar)) {
$stmt->fetch();
echo "*" . $myvar . "<br/>";
} else {
if ($stmt->errno) {
echo "Store failed: (" . $stmt->errno . ") " . $stmt->error;
}
}
} while ($stmt->next_result());
那应该像这样打印:
* 4
* 16
* 7
etc...
...然后在结果集用完后退出。相反,我得到:
* 4
Fatal error: Call to undefined method mysqli_stmt::next_result()
起初我尝试了 get_result而不是bind_result,但那出错了。基于此,我发现我没有安装 mysqlnd 驱动程序。我用bind_result解决了这个问题。现在我需要解决next_result 问题,我猜它也是 mysqlnd 驱动程序的一部分。我在这里有什么选择?技术说明:
PHP Version 5.3.2-1ubuntu4.11
谢谢。