How you can output all rows inside a database with smarty ?

Essentially, browse the database data inside a "controller" or something like that like this and send these to smarty utilizing a variable, similar to this:

$db = GetSomeDbObject();

$rows = $db->Query("Select * From aTable");
$smarty->assign("rows", $rows);
$smarty->display("index.tpl");

And, now inside a smarty file (index.tpl)

<h2>Smarty Rows</h2>
{foreach $rows as $row}
  Row Name: {$row.FieldName}
{/foreach}