[htmltmpl] Load & Display 1 Row From DBI - Best Practice?
Brought to you by:
samtregar
|
From: <ad...@sp...> - 2009-03-17 02:47:30
|
I'm using HTML::Template from CGI::Application. My template is getting
data via a SQL query where exactly one row
retrieved, and it is displayed using <TMPL_LOOP>.
What is the proper way set & display values returned from DBI when only
one row is printed? I think the method described below may have a
better alternative.
Currently showing all records using a loop:
1. $template->param(
2. RESULTS => $self->dbh->selectall_arrayref('
3. SELECT age, day FROM table WHERE id = ?',
4. { Slice => {} },
5. $self->session->param('id') )
6. );
Template:
1. <TMPL_LOOP NAME="RESULTS">
2. <TMPL_VAR NAME="age"><TMPL_VAR NAME="day">
3. </TMPL_LOOP>
-Thanks
|