mercredi 4 octobre 2017

check or condition in where clause

I want to check or condition for the variable role_id in role_mapping table. I want to check user_id has role_id either '2' or '3'.user_id '210' has role_id 2 and 1. but my query result prints '3'.How to use or condition in laravel query

Role table
  user_id role_id 
   210     2
   210     1

    $user_role=role_mapping::where('user_id','=',210)
    ->where('role_id','=','2')
    ->orwhere('role_id','=','3')
    ->select('role_mapping.role_id')->first();
     echo $user_role->role_id;  // print 3



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire