mercredi 19 juin 2019

How to imporve this Laravel query

$pfilters = ProductFilters
        ::whereIn('Tb_Product_filters.filter_value', $values)
        ->groupBy('Tb_Product_filters.product_id')
        ->join("Tb_Products","Tb_Products.id","Tb_Product_filters.product_id")
        ->join('Tb_Identities', 'Tb_Identities.id', '=', 'Tb_Products.employee_id')
        ->select(
            "Tb_Products.*",
            "Tb_Identities.first_name as fname",
            "Tb_Identities.last_name as lname"
        )
        ->get()
        ->toArray();

This query gives me all products witch in the values array , I want only the product in include all values that mean for example

if i have values = [1,2,3]

this above statement gives me any product has value_id = 1 or 2,3

I only want the product collect the 3 attrs that mean only the product has value_id = 1 and 2 and 3 it should search in many rows.



from Newest questions tagged laravel-5 - Stack Overflow http://bit.ly/31JRJFF
via IFTTT

Aucun commentaire:

Enregistrer un commentaire