So, I'm doing maintenance on a very large system. I have the query:
$query = $mysqli->query("SELECT*FROM tabela");
And the problem is that they used fetch_all()
to return the data. When the query does not return records the fetch_all()
method is not defined in the mysqli_result
class. When the query does not return records and I try to call it, I have the undefined method warning.
I've already done something like:
$resultado = $query->num_rows > 0 ? $query->fetch_all() : array();
This causes $resultado
to turn a blank array if the query does not have records returned. the problem is that there are many lines of code that should be edited. Is there a way to "create" this fetch_all()
method on the object and make it return a blank array if the query does not return records? (same or any other alternative).
@Edit
I found that mysqlnd
is missing. But the question follows: how can fetch_all()
be called even if it does not exist?
Thankful