laravel中查询数据结果集变为数组

在laravel中,查询数据库后,返回的对象,可以用下面的办法变为数组

$nodes = Db::table('system_node')->orderBy('sort', 'asc')->orderBy('id' ,'asc')->get()->map(function ($value) {
            return (array)$value;
        })->toArray();

 

posted on 2017-07-25 14:37  糖果不吃糖  阅读(9273)  评论(0编辑  收藏  举报

导航