XF 2.0 Complicated "where" clause with a finder...

Jaxel

Well-known member
How would I do this query in the new finder system?
Code:
WHERE event_state = 'visible'
    AND (
           (occur_start >= ? AND occur_start <= ?)
        OR (occur_end >= ? AND occur_end <= ?)
        OR (occur_start < ? AND occur_end > ?)
    )
 
Figured it out... you can nest additional arrays in a whereOr, and the nested arrays are grouped with an AND, while only the outside arrays have OR.

Code:
            ->whereOr([
                    ['occur_start', '>=', $start],
                    ['occur_start', '<=', $end],
                ],[
                    ['occur_end', '>=', $start],
                    ['occur_end', '<=', $end],
                ],[
                    ['occur_start', '<', $start],
                    ['occur_end', '>', $end],
                ])
 
Top Bottom