[Dbix-class] Fast way to generate a table from DBIC ResultSet

XC lihao0129 at gmail.com
Thu Jun 14 00:41:21 GMT 2007


On 6/12/07, Matt S Trout <dbix-class at trout.me.uk> wrote:
> On Tue, Jun 12, 2007 at 12:49:55AM -0400, Li Hao wrote:
> > Hi, folks:
> >
> > I am very new to DBIx::Class, so please bear with my simple questions...
> >
> > I previously use DBIx::Simple to handle DBI and it contains methods to
> > handle tables pretty easily(use DBIx::XHTML_Table). Now I am planning
> > to migrate my code to use DBIx::Class. I've read the documentations
> > several days and migrated most of my code from DBIx::Simple to
> > DBIx::Class except printing out the tables.. Could someone recommend a
> > similar module as DBIx::XHTML_Table to populate a table which work
> > with DBIx::Class?? Thanks..
>
> my $rows = $rs->cursor->all;
>
> That can go to XHTML_Table style_3.

Hi, Matt: thanks..That's exactly what I am looking for.. I've packed
it into a method of a ResultSet class... something like:

sub html
{
    my ($self, $attr, $title) = @_;
    my $rows = [ $self->cursor->all ];
    my $header = defined $title ? 0 : 1;
    return DBIx::XHTML_Table->new($rows, $title, $attr)->output({
no_header => $header});
}

everything works very well so far... I need to provide a header from
outside the resultset though. :-)

Have a good day,
XC



More information about the Dbix-class mailing list