izniburak/pdox

count(): Parameter must be an array or an object that implements Countable query->fetch()

Closed this issue · 1 comments

i try use query method;

->query("SELECT nis_rad,matric,ROUND(ST_distance(suministros.geom,centro_transformacion.geom)::numeric,2) AS distancia_mts,centro_transformacion.circuito,centro_transformacion.propietari,centro_transformacion.referencia,ROUND(centro_transformacion.cant_salbt::numeric,0)
FROM public.geo_tbl_suministros AS suministros, public.geo_tbl_transformadores AS centro_transformacion
WHERE nis_rad = ? 
AND centro_transformacion.matric = ?", [$nis,$ct])->fetch();

and recive this error message;

count(): Parameter must be an array or an object that implements Countable Pdox.php on line 752

I have corrected this with the following code

Before;

$this->numRows = count($result);
return $result;

After

if(is_array($result)){
    $this->numRows = count($result);
}
return $result;

Hi @itsalb3rt ,
I will try this and if it have any problem, i will try to fix. Thanks your feedback!