[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] OT: Class::DBI passing data to templates


Michael Cameron wrote:
This may be a silly question but...

Not at all. I had the same question when I started to integrate CDBI into CgiApp.

After the recent discussions on Class::DBI I have started looking at moving from plain DBI but have a question.  When using DBI I simply did a fetchrow_hashref and passed the resulting hashref into HTML::Template to have all the columns available as <TMPL_VAR>'s.  How can I accomplish the same thing using Class::DBI?

What I generally do is this:
(1)	$tmpl->param( map { $_->name => $obj->$_() } $obj->columns );

A quick and dirty way is using the private _data_hash method:
(2)	$tmpl->param( $obj->_data_hash );

but I prefer (1) over using a private method that may go away.

HTH,
Rhesa

---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
             http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.