Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rydurham's avatar

rydurham liked a comment+100 XP

3mos ago

Eloquent results as array instead of object

@Nospoon

Try some think like this

$query = DB::connection()->getPdo()->query("select * from users");
            
$data = $query->fetchAll(PDO::FETCH_ASSOC);
                
dd($data);

And for next row set

$array = [];

$query = DB::connection()->getPdo()->query("select * from users");

do {
         $data = $query->fetchAll(PDO::FETCH_ASSOC);
          
          if ($data) {      
            array_push($array, $data);
          }
  } while ($pdoData->nextRowset());