DBIx-XHTML_Table

 view release on metacpan or  search on metacpan

lib/DBIx/XHTML_Table.pm  view on Meta::CPAN

    bless $self, $class;

    # last arg might be GTCH (global table config hash)
    $self->{'global'} = pop if ref $_[$#_] eq 'HASH';

    # note: disconnected handles aren't caught :(

    if (UNIVERSAL::isa($_[0],'DBI::db')) {
        # use supplied db handle
        $self->{'dbh'}        = $_[0];
        $self->{'keep_alive'} = 1;
    } 
    elsif (ref($_[0]) eq 'ARRAY') {
        # go ahead and accept a pre-built 2d array ref
        $self->_do_black_magic(@_);
    }
    else {
        # create my own db handle
        eval { $self->{'dbh'} = DBI->connect(@_) };
        carp $@ and return undef if $@;
    }

lib/DBIx/XHTML_Table.pm  view on Meta::CPAN

    my ($self,$ref,$headers) = @_;
    croak "bad data" unless ref( $ref->[0] ) eq 'ARRAY';
    $self->{'fields_arry'} = $headers ? [@$headers] : [ @{ shift @$ref } ];
    $self->{'fields_hash'} = $self->_reset_fields_hash();
    $self->{'rows'}        = $ref;
}

# disconnect database handle if i created it
sub DESTROY {
    my ($self) = @_;
    unless ($self->{'keep_alive'}) {
        $self->{'dbh'}->disconnect if defined $self->{'dbh'};
    }
}

1;
__END__

=head1 NAME

DBIx::XHTML_Table - SQL query result set to XHTML table.



( run in 0.499 second using v1.01-cache-2.11-cpan-39bf76dae61 )