【发布时间】:2017-04-28 09:27:57
【问题描述】:
以下是我使用的查询,并且对我来说工作正常。
if($t_requested['category_id'])
{
$t_query_condition['p.category_id'] = $t_requested['category_id'];
}
if($t_requested['brand_id'])
{
$t_query_condition['p.brand_id'] = $t_requested['brand_id'];
}
$browseData = DB::table('products as p')
->leftjoin('categories as cp', 'p.category_id', '=', 'cp.id')
->leftjoin('brands as bp', 'p.brand_id', '=', 'bp.id')
->select('p.id as product_id','p.name as product_name','cp.title as category_name','bp.name as brand_name','p.product_weight',
'p.short_description','p.product_price','p.special_price','p.stock_quantity')
->orderBy('p.created_by', "desc")
->offset(0)
->limit(10)
->where($t_query_condition)
->get();
但现在我在“category_id”和“brand_id”中有多个 id,我想使用 whereIn 但它使用了 of 条件。如果我得到 category_id 或 brand_id 为空,则跳过。
提前致谢。
【问题讨论】:
-
Manish Patoliya: laravel 5.2 ??
-
不,它在 5.4 @KetanAkbari
标签: php jquery model-view-controller laravel-5.2