I’m querying on a table with a date field using the SQL year() funtion to filter records for a certain year.
In my PHP the following code was used:
$query = $modx->newQuery("Tariff");
$query->where(array('year(date_from)' => $year));
$tariffs = $modx->getCollection("Tariff", $query);
xPDO generates the following where claue:
WHERE `Tariff`.`year(date_from)` = '2010'
The $modx->getCollection call results in 0 objects, while there are actually records in the database with the queried year.
When I run the query in phpmyadmin, it says:
1054 - Unknown column 'Tariff.year(date_from)' in 'where clause'
Am I doing something wrong?