I need to do an Ajax request to find the maximum values of YEAR and MONTH columns in a custom table. The Ajax request is working, however the query isn’t.
The query should be something like:
select max(year), max(month) from month
I tried, based on an example I found in one of the forum posts:
$query = $modx->newQuery('Month');
$query->select('max(year), max(month');
$query->stmt->execute();
$result = $query->stmt->fetchAll(PDO::FETCH_COLUMN);
However, that generates a PHP error that "stmt" is not an object.
What would be the proper way of doing that?
Thanks.