我正在使用查询构建器,下面是我的Laravel5代码
$users = DB::table('brand_customers')
->select('brand_id')
->where('mobile', $mobile)
->take(15)
->get();我限制在15个记录,但我也在寻找总数。目前,我正在使用这个进行计数。
$users->count();我尝试了上面的代码,但没有成功。如何在同一查询中同时获取数据和计数?谢谢。
发布于 2015-04-03 21:15:21
使用两个单独的语句,如下所示:
$users = DB::table('brand_customers')
->select('brand_id')
->where('mobile', $mobile);
$count = $users->count();
$users = $users->take(15)->get();https://stackoverflow.com/questions/29432086
复制相似问题