Ideally, you would use the xPDO method for building database queries. It automatically escapes supplied arguments, creates queries that translate across database types (currently mysql & mssql), and has many other benefits. However, it's also trickier to set up as you need to create classes and maps for your custom table. Bob's guides has good info, as does Lazylegs
But of course you can implement your particular query, without using XPDO:
$leadersql = "SELECT * FROM `modx_menus`";
$query = $modx->query($leadersql);
if ($query) {
// loop through the result set and inspect one row at a time
while ($row = $query->fetch(PDO::FETCH_ASSOC)) {
array_push($rows, $row);
}
}
And there's also the Rowboat add-on, for iterating across database table rows - if your requirements are straightforward.