mysqli_fetch_all没有在共享主机上工作,需要替代方案

sk7*_*786 5 php mysql json mysqli datatables

在通过XAMPP在localhost上进行开发时,我在代码中使用了mysqli_fetch_all.但在godaddy共享主机上传后,它无法正常工作.

我在互联网上研究并发现服务器应该使用MySQLnd来运行mysqli_fetch_all.所以我无法在服务器上运行我当前的代码.

我需要这个代码的确切替代品.有什么建议?

当前代码:

$result = mysqli_query($con,$query);
$arr = mysqli_fetch_all($result, MYSQLI_ASSOC);

$totalrecords = count($arr);

$json = array('sEcho' => '1', 'iTotalRecords' => $totalrecords, 'iTotalDisplayRecords' => $totalrecords, 'aaData' => $arr);
echo json_encode($json );
Run Code Online (Sandbox Code Playgroud)

Kev*_*vin 5

如果由于未安装mysqlnd而无法使用它,则可以像通常那样使用 mysqli_fetch_assoc()

$arr = array();
$result = mysqli_query($con,$query);
$totalrecords = mysqli_num_rows($result);
while($row = mysqli_fetch_assoc($result)) {
    $arr[] = $row;
}

$json = array('sEcho' => '1', 'iTotalRecords' => $totalrecords, 'iTotalDisplayRecords' => $totalrecords, 'aaData' => $arr);
echo json_encode($json);
Run Code Online (Sandbox Code Playgroud)