I've been attempting to create an entry query that queries the same custom field twice.
Basically I want to check if a custom field is between 2 numbers OR if it is empty. Currently I'm using this to determine if the field is in range
{fieldNumber: ['and', '>=' ~ InputLow, '<=' ~ InputHigh] }
I cannot for the life of me work out how to create an additional OR for fieldNumber
in the same query.
I've looked into the Yii orWhere
option, but it's separating them with an AND
for some reason - I've tried the following as a test
{% set Query = craft.entries(queryParams) %}
{% set Query = Query.orWhere(['between', '`content`.`field_fieldNumber`', "#{1}", "#{300}" ]) %}
it produced the following SQL
AND (`content`.`field_fieldNumber` BETWEEN 1 AND 300) AND ((`content`.`field_fieldNumber` >= '58') AND (`content`.`field_fieldNumber` <= '62'))...
Ultimately I want a query that will produce something like the below, but I cannot for the life of me work out how to do it.
AND (`content`.`field_fieldNumber` = null) OR ((`content`.`field_fieldNumber` >= '58') AND (`content`.`field_fieldNumber` <= '62'))...
Has anyone got any ideas, or can anyone point me in the right direction?
Much appreciated.