【发布时间】:2020-03-22 21:37:51
【问题描述】:
!在将数组中的所有 id 分组后,从原始查询 #2 中的周数获取周开始日期和周结束日期
$test=DB::table('bookings')
->select([
'bookings.organization_id',
DB::raw('week(bookings.created_at) as week'), // this give me week number I need start date and end date starting date Sunday and end date Saturday
DB::raw('year(created_at) as year'),
按组织 ID 分组后的第二个我需要数组中的所有预订 ID 而不是字符串
// I try this but give like this "1,4,6,7,9" I need ["1","4","6","7","9"]
DB::raw('group_concat(bookings.id) as bookings_id'),
【问题讨论】:
-
为什么不能迭代结果集并填充数组?
-
两个问题 #1 将周数更改为开始日期和结束日期。我是 db raw 的新手,我需要代码才能理解。谢谢