close
Q:
Hi there,
I have a large SQL statement that I am executing like so...
$result = DB::select($sql);
I'd like the result to be an array - but at the moment it returns a structure like so, an array with Objects...
Array
(
[0] => stdClass Object
(
[field] => 6
)
...etc...
Any advice much appreciated...
A:
使用->toArray()這個function
UPDATE: Indeed it still returning objects inside, as @pixelgremlins said, working using collect($data)->map(function($x){ return (array) $x; })->toArray()
--
轉自 https://laravel.io/forum/10-14-2014-dbselect-toarray
--
全站熱搜
留言列表