I am using Class::DBI and HTML::Template with CGI::Application. To speed the process of providing HTML::Template with the hashes it requires I recently added the following to my subclass:
Code originally from PodMaster in Re: Getting HASHES out of Class::DBI. To return HASHREF's which I can pass to HTML::Template. This is fine if the method is called on a Class::DBI object. But what if I have an iterator? OK, I can 'wrap' hashy in a WHILE loop and push the returned HASHREF's onto a list and voila I can pass it to a <TMPL_LOOP..>.package AppSys::DBI; use base 'Class::DBI::mysql'; sub hashy { my $self = shift; return { map { my $g = $self->get($_); $g = hashy($g) if ref $g; ( $_ => $g ); } $self->columns }; }
My question is how do I go about determining which Class I am being called from? Am I a Class::DBI object and thus a single record being returned, or am I a Class::DBI::Iterator and thus I can iterate over myself and return a ref to a list of hashes.
In reply to Help with extending Class::DBI please. by jdtoronto
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |