That didn't make any sense whatsoever. 

DBI does not return column names in results. 

 H-T needs column names to assign values to <TMPL_VAR NAME=VARNAME>

 So How is it possible to use $template->param(ROWS => $sth->fechall_arrayref({}));
 when arrayref does not supply H-T what needs to perform it's function?

----- Original Message ----- 
From: "Andrew Brosnan" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, September 26, 2002 1:20 PM
Subject: Re: [htmltmpl] HTML-Template and DBI


> On 9/26/02 at 12:54 PM, [EMAIL PROTECTED] (Doc) wrote:
> 
> > What about  tha fact dbi array doesn't contain column names?
> 
> huh? If you (SELECT foo, bar, FROM db) returned will be a ref to the
> values of foo & bar for each row that your querry matched.
> 
> 
> 
> Have you looked at the 'bind columns' method? (untested):
> 
> my $sth = $dbh->prepare( qq{ SELECT foo, bar FROM db WHERE [blah...] })
>     or die [blah...] ;
>     
> $sth->execute()
>     or die [blah...] ;
>     
> $sth->bind_columns(undef, \my($foo, $bar,))
>     or die [blah...];
>     
> $sth->fetch;
> 
> #Now feel free to use $foo and $bar
> 
> $template->param(foo    => $foo,
>                  bar    => $bar);
> 
> 
> 
> 
> #For loops something like:
> 
> my @loop;
> 
> while(my $data = $sth->fetch) {
> 
>     my %row = ( foo     => $foo,
>                 bar => $bar, );
>     push (@loop, \%row);
>     
> }
>     
> $template->param(stuff  => \@loop,);
> 
> 
> 
> 
> 
> > ----- Original Message ----- 
> > From: "Ben Ausden" <[EMAIL PROTECTED]>
> > To: "Doc" <[EMAIL PROTECTED]>
> > Cc: <[EMAIL PROTECTED]>
> > Sent: Thursday, September 26, 2002 4:52 AM
> > Subject: RE: [htmltmpl] HTML-Template and DBI
> > 
> > 
> > 
> > > -----Original Message-----
> > > From: Doc [mailto:[EMAIL PROTECTED]]
> > > Sent: 26 September 2002 05:12
> > > To: Norikatsu Shigemura
> > > Cc: [EMAIL PROTECTED]
> > > Subject: Re: [htmltmpl] HTML-Template and DBI
> > > 
> > > 
> > > I just realized something, doesnt fetch_array return column 
> > > values and not column names? And data has to be in this format
> > > 
> > > $template->param(EMPLOYEE_INFO => [ 
> > > { name => 'Sam', job => 'programmer' },
> > > { name => 'Steve', job => 'soda jerk' },
> > > ]);
> > > 
> > >  I tried printing every dbi fetch results and they dont turn 
> > > out that. just {HASH} and bunch of numbers. 
> > > 
> > 
> > You can't print a hashref - get hold of the Data::Dumper module from
> CPAN if you 
> > haven't already, and do:
> > 
> > use Data::Dumper;
> > print Dumper($name_of_my_hashref);
> > 
> > 
> > Data::Dumper will pretty-print data structures for you - very useful
> for 
> > debugging.
> > 
> > 
> > With regard to $sth->fetchall_arrayref(), by default it returns an
> array 
> > reference containing an array ref for each row. HOWEVER, if you pass
> it an empty  
> > hash reference like so: $sth->fetchall_arrayref( {} ), it will return
> a 
> > reference to an array containing a hashref for each row... which is
> exactly what 
> > you need for an HTML::Template loop (as described in the example you
> quoted 
> > above). See the DBI manpages http://www.perldoc.com/cpan/DBI.html
> > 
> > 
> > regards,
> > Ben 
> > 
> > 
> 
> 
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Html-template-users mailing list
> [EMAIL PROTECTED]
> https://lists.sourceforge.net/lists/listinfo/html-template-users



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to