我在 Windows 上运行 MAMP。 php_mysqli.dll 在 php.ini 文件中启用。
除此之外,在 php 信息中它表示 mysqlnd 已启用:
这是我的 php 的样子:
$connection = connect();
if($stmt = $connection->prepare("SELECT * FROM `users` WHERE `email` = '?'")){
$stmt->bind_param("s", $email);
$stmt->execute();
$result = $stmt->get_result();
}
行$result = $stmt->get_result()
抛出错误
PHP Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::get_result()
有什么猜测为什么 get_result()
不起作用吗?
这与已经提出的问题不同,因为所有解决方案都提到 mysqlind 未启用,但就我而言,它是启用的。
最佳答案
如果您切换到 PDO,您可以使用 fetchAll
反而。 PDO 优于 mysqli 有几个原因,其中之一包括在执行之前将数组作为参数传递的能力。
关于php - 未捕获错误:调用 mamp 中未定义的方法 mysqli_stmt::get_result(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35901248/