[Templates] foreach problem with a one row result
[prev]
[thread]
[next]
[Date index for 2004/07/19]
hello everyone
this is my first post to this list so i'm not sure what all information i should supply
also, i'm new to this template library
but enough of my "i'm a newbie schtick" here goes
i wrote a template and have a database and things work as far as rendering, etc
but i've noticed that if i have only one row come back in my query/resultset, then i seem to get a garbage result set back to the template in the foreach loop
i didn't know what was going on, and on a lark, i added a dummy value to the return array in addition to the result and it worked fine (except of course, i now get a dummy value back that i'd have to check for to remove and thus render properly)
the code in the template
[% FOREACH item = weightLossFeatures %]
<img border="0" src="images/[% item.image %]">
[% END %]
which is defined like this
sub handler {
(snip)
my @parameters = {
uri => $request->uri(),
cgi => CGI->new(),
all => \&allRecords,
weightLossFeatures => \&weightLossFeatures,
mealReplacementsFeatures => \&mealReplacementsFeatures,
proHormonesFeatures => \&proHormonesFeatures,
vitaminsFeatures => \&vitaminsFeatures,
manHealthFeatures => \&manHealthFeatures,
womanHealthFeatures => \&womanHealthFeatures
};
my $uri = substr($request->uri(), 1);
unless($template->process($uri, @parameters) ) {
$request->log_error("Template failed to process", $template->error());
return FAIL;
}
return OK;
}
and the weightLossFeatures sub returns a resultset from a query to a mysql db
it seems to work from the command line fine, but when it's run through my apache server
Server version: Apache/1.3.31 (Debian GNU/Linux)
Server built: Jun 24 2004 22:53:01
Server's Module Magic Number: 19990320:16
Server compiled with....
-D EAPI
-D HAVE_MMAP
-D HAVE_SHMGET
-D USE_SHMGET_SCOREBOARD
-D USE_MMAP_FILES
-D HAVE_FCNTL_SERIALIZED_ACCEPT
-D HAVE_SYSVSEM_SERIALIZED_ACCEPT
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D DYNAMIC_MODULE_LIMIT=64
-D HARD_SERVER_LIMIT=4096
-D HTTPD_ROOT="/usr"
-D SUEXEC_BIN="/usr/lib/apache-perl/suexec"
-D DEFAULT_PIDLOG="/var/run/apache-perl.pid"
-D DEFAULT_SCOREBOARD="/var/run/apache-perl.scoreboard"
-D DEFAULT_LOCKFILE="/var/run/apache-perl.lock"
-D DEFAULT_ERRORLOG="/var/log/apache-perl/error.log"
-D TYPES_CONFIG_FILE="/etc/mime.types"
-D SERVER_CONFIG_FILE="/etc/apache-perl/httpd.conf"
-D ACCESS_CONFIG_FILE="/etc/apache-perl/access.conf"
-D RESOURCE_CONFIG_FILE="/etc/apache-perl/srm.conf"
and mysql
/usr/sbin/mysqld Ver 4.0.20 for pc-linux-gnu on i686 (Source distribution)
Apache::Template is version .09
Template.pm is version 2.10
aaron
--
Let's just be friends
the type of friends that make no special effort to see each other
_______________________________________________
templates mailing list
templates@xxxxxxxxxxxxxxxx.xxx
http://lists.template-toolkit.org/mailman/listinfo/templates
 |
[Templates] foreach problem with a one row result
Good Times 22:31 on 19 Jul 2004
|