调用未定义的方法mysqli_stmt :: get_result [英] Call to undefined method mysqli_stmt::get_result

查看:80
本文介绍了调用未定义的方法mysqli_stmt :: get_result的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

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()

I get the error on last line as: Call to undefined method mysqli_stmt::get_result()

这是conn.php的代码:

Here is the code for 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对象在项目中的其他查询中可以正常工作.

It prints 'Statement NOT prepared'. If I run the query directly in the IDE replacing ? marks with values, it works fine. Please note that $conn object works fine in other queries in the project.

请帮助.......

推荐答案

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

Please read the user notes for this method:

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

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

It requires the mysqlnd driver... if it isn't installed on your webspace you will have to work with BIND_RESULT & FETCH!

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

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

这篇关于调用未定义的方法mysqli_stmt :: get_result的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆