vendredi 25 septembre 2015

Convert SQL to Laravel Query Builder with complex AND OR

I have a query like this-

SELECT * FROM subscribers_lists
  WHERE Country='Germany'
  AND (City='Berlin' OR name LIKE '%Mün%');

I want to convert it to a Laravel query builder's query. So, what I have done is -

DB::table('Customers')
    ->where('subscribers_lists.Country', '=', $user_country)
    ->or_where('subscribers_lists.City', '=', $user_city)
    ->or_where('subscribers_lists.name', 'like', '%' . $searchParameter . '%');

But it is not working perfectly. Any suggestion, please?

Thanks for helping.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire