$ mysqli-> fetch_all不起作用

时间:2017-10-23 19:23:46

标签: php mysqli

我正在尝试使用此代码来获取所有数据但不起作用。

我的数据库连接代码

function initializeConnection(){
    $host       =   "localhost";
    $username   =   "xxx";
    $password   =   "xxx";
    $dbName     =   "xxx";
    $mysqli = new mysqli($host, $username, $password, $dbName);

    if (mysqli_connect_errno()) {
        die('Could not connect: ' . mysqli_connect_error());

    }
    return $mysqli;
}

我的dfetch数据代码

function getResultFetchAll($sql){
    global $mysqli;
    $mysqli = initializeConnection();
    $result = $mysqli->query($sql);
    return $mysqli->fetch_all(MYSQLI_ASSOC);
}

显示错误

PHP Fatal error:  Uncaught Error: Call to undefined method mysqli_result::fetch_all() 

0 个答案:

没有答案