The easiest way is to simply use the PDO methods, something like this when used in MODx Revolution...
This is a pretty general question of how to return single value results via xPDO, such as SELECT MAX(column) FROM table_name.
Any help will be appreciated
<?php
$stmt = $modx->query("SELECT MAX(id) FROM {$modx->getTableName('modResource')}");
$maxId = (integer) $stmt->fetch(PDO::FETCH_COLUMN);
$stmt->closeCursor();
?>When using fetch(), instead of fetchAll() which fetches the entire result set at once, you should always explicitly closeCursor(). If you do not fetch all rows of a result set, some environments can lose their connection to the database server when the next query is attempted.
What is the closeCursor about ?