$res=DB::select('select * from qq');
var_dump($res);
$res=DB::table('qq')->get();
var_dump($res);
Why is a one-dimensional array obtained in the picture after querying in these two ways? Why are there objects in one-dimensional arrays? What we get using native query is a two-dimensional array. Why is the result not a two-dimensional array?
Run the native SQL query and get a result set in the form of an array. See the documentation for details.
Use the Query Builder to run the SQL statement and get a Collection object. See the documentation for details.
What you get when you run a native SQL statement is a one-dimensional array wrapped in objects, not a two-dimensional array.
What you get using the query constructor is a Collection object, which is also a one-dimensional array wrapping each object. So why return the Collection object, because it has many useful and elegant methods built in. Just like Eloquent returns Collection objects by default.