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

(This post was last modified: 03-06-2023, 09:11 AM by iRedds.)

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
Reply


Messages In This Thread
RE: Is method chaining order significant in query builder? - by iRedds - 03-06-2023, 09:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB