NAME

HTML::DataTable::DBI - Print HTML tables from SQL queries

VERSION

Version 0.5

SYNOPSIS

use HTML::DataTable::DBI;
my $list = HTML::DataTable::DBI->new(
  data => $cgi_data,
  columns => [
    # hashrefs describing column formats
  ],
  sql => 'SELECT * FROM table_name WHERE foreign_key = ?',
  sql_params => [ $some_value ],
  delete =>
);
print $list;

METHODS

Look in HTML::DataTable for column-definition and table formatting attributes

ADDITIONAL ATTRIBUTES

dsn

A list containing a DBI connect string, username, and password.

dbh

You can supply a live DBI database handle instead of a DSN.

sql

A SQL query with optional "?" placeholders, which will be run and its results formatted and shown in the table.

sql_params

An optional arrayref containing the actual parameters for the SQL query.

delete

An optional hashref telling the list what record to delete. If this is included, a column will be added to the table to show trash icons. The hashref can take either of two forms. If the SQL query for this table is not parameterized – that is, the record's ID is all we need to know which record to delete, then the hashref can simply map the column index of the record ID to the CGI argument that supplies the one to delete:

delete => {
  sql => 'DELETE FROM table WHERE record_id = ?',
  id => [ 0 => $args{delete} ],
}

whereas if the query had a parameter the delete hashref has to give both the local and foreign keys:

delete => {
  sql => 'DELETE FROM table WHERE record_id = ? AND foreign_id = ?',
  local => [ record_id => $args{speaker_id} ],
  foreign => [ 0 => $args{delete} ],
}

An optional "noun" attribute in that hashref can supply a word to replace "record" in the delete confirmation alert.

trash_icon

The URL of a trash can icon for use in the "Delete" column – defaults to /art/trash.gif.

SEE ALSO

HTML::DataTable

AUTHORS

Nic Wolff <nic@angel.net> Jason Barden <jason@angel.net>

1 POD Error

The following errors were encountered while parsing the POD:

Around line 60:

Non-ASCII character seen before =encoding in '– that'. Assuming UTF-8