从 laravel 控制器输出中获取所需列数据的计数
Get count of only required column data from a laravel controller output
$selected_subcats2 = EstablishmnetSubcategories::Join('establishments','establishments.id','=','establishment_subcategories.establishment_id')->where('establishment_subcategories.establishment_id',$establishment_id)->get(array('establishment_subcategories.status as status'));
Result:[{"status":0},{"status":1},{"status":1},{"status":0},{"status":0}]
这是我的控制器条件和输出,在上面的输出中我想获得值为零的状态计数。我不想全部计数,怎么可能只获得状态零计数,请帮助...谢谢
试试这个
在您的查询中添加 where('status',0)
它会起作用
$selected_subcats2 = EstablishmnetSubcategories::Join('establishments','establishments.id','=','establishment_subcategories.establishment_id')->where('establishment_subcategories.establishment_id',$establishment_id)->get(array('establishment_subcategories.status as status'));
Result:[{"status":0},{"status":1},{"status":1},{"status":0},{"status":0}]
这是我的控制器条件和输出,在上面的输出中我想获得值为零的状态计数。我不想全部计数,怎么可能只获得状态零计数,请帮助...谢谢
试试这个
在您的查询中添加 where('status',0)
它会起作用