What about  tha fact dbi array doesn't contain column names?

----- 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