Mysqli_fetch_all alternative needed

I have php-mysqli code that works, find one of my local server, but when using it on my server I get

Fatal error: Call to undefined function mysqli_fetch_all() in /home3/t561257/public_html/admin/database.php on line 49 

The next part of the code is the problem.

  function fetch_rows($queryname) { $result = $this->connection->query($queryname); $row = mysqli_fetch_all($result, MYSQLI_ASSOC); return $row; } 

I use it as follows

  $next_four_rows = $db_link->fetch_rows($query_four_latest); 

$ db_link is a class that has a fetch_rows method.

I am using php 5.5 on my local server running 5.4.27 server. I really don't know how to fix this.

+6
source share
1 answer

If mysqli_fetch_all not available because your PHP installation was not compiled using mysqlnd , you have two options:

  • Recompile PHP with mysqlnd or possibly install another specific package from your Linux distribution repository.
  • Use a simple loop:

     $data = []; while ($row = $result->fetch_assoc()) { $data[] = $row; } 
+10
source

Source: https://habr.com/ru/post/974643/


All Articles