我有一个很长的SQL语句,我是这样执行它的:
$result = DB::select($sql);
例如
$result = DB::select('select * from users');
我希望结果是一个数组,但现在它返回的是这样的结构,一个包含对象的数组...Array
(
0 => stdClass::__set_state(array(
'id' => 1,
'first_name' => 'Pavel',
'created_at' => '2015-02-23 05:46:33',
)),
1 => stdClass::__set_state(array(
'id' => 2,
'first_name' => 'Eugene',
'created_at' => '2016-02-23 05:46:34',
)),
...etc...
)
$result = array_map(fn($x) => (array)$x, $result);
- Bishal Paudel