Laravel: Proper way to use Where and orWhere in query -
There is currently a query running in Laravel but the expected output is not correct. Therefore, it seems that I still do not know the proper way to use where / or somewhere
I have these two questions below;
QUERY 1 (A)
// Total Friend $ user = Friend :: Select ('friend_sender (' Friend_receiver ') - Where ('friend_sender', input :: get ("user_id")) - gt; or where ('friend_receiver', input :: find ("user_id")) -> ('friendship_status', 'Friends') - & gt; Count ();
QUERY 1 (b)
// Total Friends $ User = Friend :: Select ('friend_sender', '(' Friend_receiver ') -> where (' friendship_status', 'friends') -> where (' friend_sender ', get input :: ("user_id ")) - or (where 'friend_receiver', input :: get (" user_id ")) - & gt; count ();
These two questions produce different results.
QUERY 1 (a)
result is0
, which is true in my own example andQUERY 1 (b)
result1
that is wrong.Now, I think that
WHEREs
isWHERE / orWHERE
must come after the statement. I have written another question but not found the necessary results.$ user = Friend :: Select ('friend_sender', 'friend_receiver') - & gt; Where ('friend_sender', get input :: ("user_id")) - & gt; Or where (where '(friend_receiver'), input :: find ("user_id")) - & gt; Where ('sender_follow', 'yes') - gt; Or where ('receiver_follow', 'yes') - & gt; Where ('friendship_status', 'friend') - & gt; Count ();
My question is, how do I use
WHERE / orWHERE
properly?
View this example from:
DB :: table ('Users') - & gt; Where ('name', '=', 'john') - & gt; Or where (function ($ query) {$ query-> where ('vote', '& gt;', 100) -> where ('title', '
The closure will say: and before, again or the situation.
Comments
Post a Comment