Monday, March 20, 2017

Getting wrong ids in an eloquent query

I made a query who return me results with also "Licencies" from structure_id who are differents from = 4 . everything is good good with just the where clause but if i had another condition with an orWhere then the query display me also resultat from differents structure_ids ... Anyone knows the right query to got only the good structure id with the two where clause ? thanks a lot in advance

here my query :

$licencies = Licencies::where('structure_id' ,  '4')->where('statut_licence_id' , '2')->orWhere('valid_licence_id' , '1')->get();

here the query when i run the code :

select * from `licencies` where `structure_id` = '4' and `statut_licence_id` = '2' or `valid_licence_id` = '1'

but in the result i get also licencies from structure_id = 5 for exemple



via Mathieu Mourareau

Advertisement