What about open the documentation?
https://laravel.com/docs/8.x/queries#retrieving-all-rows-from-a-table
https://laravel.com/docs/8.x/queries#retrieving-a-single-row-column-from-a-table
Maybe you'll see the difference.
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
How to get the following query result into an array instead of an object ?
$res = DB::connection('myconn')->table('mytable')->where('MYID', $id)->first();
You mean like casting stdClass to the array?
$res = (array) DB::connection('myconn')->table('mytable')->where('MYID', $id)->first();
Please or to participate in this conversation.