Welcome Guest, Not a member yet? Register   Sign In
Is method chaining order significant in query builder?
#3

(03-06-2023, 09:10 AM)iRedds Wrote: SQL doesn't read minds. The query is executed as written.

a AND b OR c  === (a + b) OR c
b OR c AND a  === b OR (c + a)

The fact that your query works in one case but fails in another only means that you don't have enough data.

You need to group conditions. a AND (b OR c)

PHP Code:
->groupStart()
  ->like('birthday''-03-')
  ->orLike('birthday''-04-')
->
groupEnd()
->
where('active'1

Or an alternative for SQLite (if the table field is in date format)

PHP Code:
->whereIn('strftime(%m, birthday)', [34], false)
->
where('active'1
Well, thanks! I did not expect I was so inexperienced.
==

Donatas G.
Reply


Messages In This Thread
RE: Is method chaining order significant in query builder? - by dgvirtual - 03-06-2023, 11:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB