It’s much better to use the API here:
<?php
// use the API to build the query
$q = array(
'parent' => 9,
'deleted' => false,
'published' => true
);
$query = $modx->newQuery('modResource', $q);
$query->sortby('menuindex', 'ASC');
// get the distinct modResource rows that would be selected by this query
// NOTE: this is typically more useful with limit() usage
$numRows = $modx->getCount('modResource', $query);
// you can use xPDO::getCollection() or xPDO::getIterator() here
// to fetch the rows as objects, take advantage of caching, etc.
$iterator = $modx->getIterator('modResource', $query);
foreach ($iterator as $resource) {
echo $resource->get('pagetitle');
}
This will be increasingly important for backwards compatibility as we progress forward and the table structures start to change, cross-platform compatibility, and for taking better advantage of advanced features like result set caching.