# prepare the SQL
my $sth = $dbh->prepare('select * from table');
# execute
$sth->execute();
# fetch first row
my @row = $sth->fetchrow_array();
# print remaining rows
while (my @row = $sth->fetch_array()) {
print join(',', @row), "\n";
}
####
my $res = $dbh->selectall_arrayref('select * from table');
foreach my $row (@$res) {
print join(',', @$row), "\n";
}
# html-table style
print "\n";
foreach my $row (@$res) {
print "\t\n";
print map { "\t\t| $_ | \n" } @$row;
print "\t
\n";
}
print "
\n";
####
use DBIx::XHTML_Table;
my $table = DBIx::XHTML_Table->new(
'DBI:mysql:database:host', 'user', 'pass')
) || die;
$table->exec_query('select * from table');
print $table->output();
####
print DBIx::XHTML_Table
->new('DBI:mysql:database:host', 'user', 'pass')
->exec_query('select * from table')
->output();