致命错误:调用未定义方法mysqli_result::fetch_all()任何方法使其向后兼容php 5.2


Fatal error: Call to undefined method mysqli_result::fetch_all() Any way to make this backward compatible with php 5.2

我将我的代码从测试服务器移动到主机,我收到这个错误:

Fatal error: Call to undefined method mysqli_result::fetch_all()

我用fetch_all编写了这么多行代码,要全部修改会很麻烦。

解决这个问题最简单的方法是什么?

示例php:

function get_all_map_users() {
        $mysqli = new mysqli(DB_HOST,DB_USER,DB_PASSWORD,DB_NAME);
        if ($mysqli->connect_error) {
            //Failed to connect
            die('Could not connect: ' . $mysqli->connect_error . ' - ' . $mysqli->connect_errno);
        }
        //Success
                            $result = $mysqli->query("SELECT * FROM names");
                            $rows = $result->fetch_all(MYSQLI_ASSOC);
                            //Clear result set
                            $result->free();
        //End mysql query
        //Close mysqli connection
        $mysqli->close();
        return $rows;
}

在Hostgator上启用PHP 5.3: http://support.hostgator.com/articles/hosting-guide/hardware-software/php-5-3.