I am getting data using the below query but I am passing the parameter to where clause but it convert the parameter to a question mark (?).
$productDatas = DB::table('products')->select('products.*','products.id as pid','product_features.*','product_features.id as pfid')->join('product_features','product_features.product_id','=','products.id')->join('categories','categories.id','=','products.cat_id','left');
if($value == 13){
// $value = intval($value);
$productData = $productDatas->where('product_features.'.$field,'<',$value)->toSql();
dd($productData);
}else{
$productData = $productDatas->where('product_features.'.$field,'=',$value)->get();
}
And the Output of query:
"select `products`.*, `products`.`id` as `pid`, `product_features`.*, `product_features`.`id` as `pfid` from `products` inner join `product_features` on `product_features`.`product_id` = `products`.`id` left join `categories` on `categories`.`id` = `products`.`cat_id` where `product_features`.`primary_camera` < ?"
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire