简体   繁体   English

如何解析查询生成器结果?

[英]How can i parse the query builder result?

I use query builder for select data from DB. 我使用查询生成器从数据库中选择数据。 My query builder is : 我的查询生成器是:

    $end_date = DB::table('synon_library_lending')
    ->where('end_date', '<', Carbon::today())
    ->pluck('end_date', 'id');

and the result of this query is: {"4":"2019-07-03","5":"2019-07-04"} My problem is: i can't parse the above statement in php? 并且此查询的结果是:{“ 4”:“ 2019-07-03”,“ 5”:“ 2019-07-04”}我的问题是:我无法在php中解析以上语句? What's your solution for this problem? 您如何解决此问题?

For show result of query builder use foreach like this code: 对于查询生成器的显示结果,使用如下所示的foreach:

 $lists = User::orderBy('first_name')
        ->orderBy('last_name')->get();
    if ($lists->count()) {
        foreach ($lists as $item) {
            $list[$item->id] = "$item->first_name $item->last_name";
        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM