Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/visual-studio-2008/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何正确替换get_result()函数_Php_Mysqlnd - Fatal编程技术网

Php 如何正确替换get_result()函数

Php 如何正确替换get_result()函数,php,mysqlnd,Php,Mysqlnd,我在我的php文件中使用了类似的函数,但主机没有mysqlnd 那么,如何正确地替换get\u result()函数呢 我已经看到了一个解决方案,但是没有实现它,所以请给我一个例子。谢谢 public function getFromDb($tableName) { $stmt = $this->conn->prepare("SELECT * FROM ".$tableName); $stmt->execute(); $result= $stmt->

我在我的php文件中使用了类似的函数,但主机没有mysqlnd

那么,如何正确地替换
get\u result()
函数呢

我已经看到了一个解决方案,但是没有实现它,所以请给我一个例子。谢谢

public function getFromDb($tableName) {
    $stmt = $this->conn->prepare("SELECT * FROM ".$tableName);
    $stmt->execute();
    $result= $stmt->get_result();
    $stmt->close();
    return $result;
}
MySQLi
prepare()。因此,您的函数可能如下所示:

public function getFromDb($tableName) {
    $result = $this->conn->query("SELECT * FROM ".$tableName);
    if (empty($result)) {
        return FALSE;
    }
    return $result->fetch_assoc();
}

替换为什么?语法和格式任何alternative@DerVO