我使用查询生成器从数据库中选择数据。我的查询生成器是:
$end_date = DB::table('synon_library_lending')
->where('end_date', '<', Carbon::today())
->pluck('end_date', 'id');
,此查询的结果是: {“ 4”:“ 2019-07-03”,“ 5”:“ 2019-07-04”} 我的问题是:我无法在php中解析以上语句? 您对此问题有什么解决办法?
答案 0 :(得分:0)
对于查询生成器的显示结果,使用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";
}
}