Rhesa Rozendaal wrote:
> 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.
I've also been thinking about using Class::DBI with HTML::Template as well.
I like the idea of #1 but how do you handle has_a and has_many
relationships? Browsing the Class::DBI pod I would imagine that the has_a
would "do the right thing" but I'm not sure how you would handle has_many
with H::T and loops.
I've been going back and forth between using something like Class::DBI vs.
using straight SQL in objects similar to Krang.
> HTH,
> Rhesa
Thanks,
Charlie
---------------------------------------------------------------------
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.