[cgiapp] Proper Way To Load Template Params

adam at spatialsystems.org adam at spatialsystems.org
Sun Mar 15 23:33:52 EDT 2009


My template is getting data via a SQL query.  There is exactly one row
retrieved.
 
Currently I use the below method to show all records using a loop:
$template->param(
  RESULTS => $self->dbh->selectall_arrayref('
    SELECT age, day FROM table WHERE id = ?',
    { Slice => {} },
    $self->session->param('cell')->{'sid'} )
);


Template:
<TMPL_LOOP NAME="RESULTS">
  <TMPL_VAR NAME="age"><TMPL_VAR NAME="day">
</TMPL_LOOP>


But how should I load the template if I have exactly one row returned? 
I could fudge it and use the loop to iterate of the one row, but I think
that may be a sub optimal method.


-Thanks





More information about the cgiapp mailing list