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 is 0 , which is true in my own example and QUERY 1 (b) result 1 that is wrong.

Now, I think that WHEREs is WHERE / 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

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -