I'm trying to do an andWhere()
"OR" group for a special criteria value so basically when building an element criteria I want to just set `$criteria->upcomingOnly to true, and then have the following code run. The problem is that the greater than or equal to is being added to the value and its doing an equals comparison on it which obviously is going to return nothing. Anyone have any idea what I need to change to get desired result?
if($criteria->upcomingOnly) {
$today = new DateTime('now');
$query->andWhere(['or',
['events.eventStart' => '>= ' . $today->format('Y-m-d')],
['events.eventEnd' => '>= ' . $today->format('Y-m-d')]
]);
}
Basically the resulting query is
WHERE ((elements_i18n.locale = :locale) AND (elements.archived = 0)) AND ((`events`.`eventStart`=:pzek8XoNML) OR (`events`.`eventEnd`=:pZQmaPhwE8))
GROUP BY `elements`.`id`
ORDER BY `eventStart` ASC LIMIT 50. Bound with :locale='en_us', :pzek8XoNML='>= 2017-10-06', :pZQmaPhwE8='>= 2017-10-06'
And I would like to get something like this:
WHERE ((elements_i18n.locale = :locale) AND (elements.archived = 0)) AND ((`events`.`eventStart`>=:pzek8XoNML) OR (`events`.`eventEnd`>=:pZQmaPhwE8))
GROUP BY `elements`.`id`
ORDER BY `eventStart` ASC LIMIT 50. Bound with :locale='en_us', :pzek8XoNML='2017-10-06', :pZQmaPhwE8='2017-10-06'