php - 调用未定义的方法mysqli_stmt::get_result

标签 php mysqli

这是我的代码:

include 'conn.php';
$conn = new Connection();
$query = 'SELECT EmailVerified, Blocked FROM users WHERE Email = ? AND SLA = ? AND `Password` = ?';
$stmt = $conn->mysqli->prepare($query);
$stmt->bind_param('sss', $_POST['EmailID'], $_POST['SLA'], $_POST['Password']);
$stmt->execute();
$result = $stmt->get_result();

我在最后一行收到以下错误:调用未定义的方法mysqli_stmt::get_result()

这是conn.php的代码:
define('SERVER', 'localhost');
define('USER', 'root');
define('PASS', 'xxxx');
define('DB', 'xxxx');
class Connection{
    /**
     * @var Resource 
     */
    var $mysqli = null;

    function __construct(){
        try{
            if(!$this->mysqli){
                $this->mysqli = new MySQLi(SERVER, USER, PASS, DB);
                if(!$this->mysqli)
                    throw new Exception('Could not create connection using MySQLi', 'NO_CONNECTION');
            }
        }
        catch(Exception $ex){
            echo "ERROR: ".$e->getMessage();
        }
    }
}

如果我写这行:
if(!stmt) echo 'Statement prepared'; else echo 'Statement NOT prepared';

它打印'未准备的声明'。如果我直接在IDE中运行查询替换?用值标记,效果很好。请注意,$ conn对象在项目中的其他查询中可以正常工作。

请帮忙.......

最佳答案

请阅读此方法的用户说明:

http://php.net/manual/en/mysqli-stmt.get-result.php

它需要mysqlnd驱动程序...如果未在您的网站空间中安装它,则必须使用BIND_RESULT&FETCH!

https://secure.php.net/manual/en/mysqli-stmt.bind-result.php

https://secure.php.net/manual/en/mysqli-stmt.fetch.php

关于php - 调用未定义的方法mysqli_stmt::get_result,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61901285/

相关文章:

php - libdb4.6-dev 与 libdb4.7-dev

php - mysql_real_escape_string 和 strip_slashes 问题

PHP Curl,请求数据返回application/json

php - 查询未选择表中的所有行

php - 在 while 循环中从每篇文章的评论和图片表中选择

PHP MySQLi 从索引处的表中选择行

PHP 购物车 添加项目

php - SQL 中的变量不适用于准备语句

php - 使用 prepare 命令更新我的表,将值增加 2

php - 我如何将其转换为 mysqli