The DBAPI ($modx->db->...) was something heavily used in Evolution, and it was included in Revolution to provide easier migration from Evolution to Revolution, however in 2.1 (which should be the next release) it wont be available anymore, so your script will then break.
xPDO or MODX Objects aren’t that hard to learn. For example, these are the first two linen of your code:
$temp= $modx->db->query("Select id, pagetitle, template From `modx_site_content` WHERE template=5");
while($row = $modx->db->getRow($temp)) { ... }
In Revolution you would do this slightly differently:
$c = $modx->newQuery('modResource');
$c->where(array(
'template' => 5));
$result = $modx->getCollection('modResource',$c);
foreach ($result as $row) {
...
}
Within the foreach, $row is an object which gives you access to all fields needed.
For example $row->get(’pagetitle’), but you could also do $row->getOne(’template’)->get(’name’) and much, much more. You could look on the rtfm for more information on xPDO.