DBIx::HTML::ClientDB is a Perl module to convert sql into a client-side db with keyed access. Synopsis use DBIx::HTML::
DBIx::HTML::ClientDB is a Perl module to convert sql into a client-side db with keyed access.
my($object) = DBIx::HTML::ClientDB -> new
dbh => $dbh,
row_headings => 'Unit code,Unit code,Campus name,Unit name',
sql => 'select unit_code, unit_code, campus_name, unit_name ' .
'from unit, campus where unit_campus_id = campus_id ' .
'order by unit_code',
print $object -> table();
This module takes a db handle, an SQL statement and a specially-formatted row_headings parameter, and builds an array of rows as returned by the SQL.
Then you ask for that array in HTML, ie as a table.
After a call to the table() method, you can call the size() method if you need to check how many rows were returned by the SQL you used.
Neither the module CGI.pm, nor any of that kidney, are used by this module. We simply output pure HTML.
However, for simplicity, this document pretends you are using CGI.pm rather than an alternative. The sentences would become too convoluted otherwise.
The output table is formatted as N rows of 2 columns:
The first column contains the row headings you supply in the 'row_headings' parameter. 'row_headings' is a comma-separated list of strings you want to appear in the first column of the table.
There must be one string in 'row_headings' for each column mentioned in the SQL.
The second column contains the 'current record' in the database.
Now for the rows:
The first row contains the first prompt string in the first column.
The first row contains a HTML popup menu in the second column.
This menu is what you use to choose the 'current record' in the database.
Since two (2) SQL columns are used to build this menu, two (2) strings from the row_headings parameter are consumed building the first row. The first of these 2 strings appears in the first column, as explained above. The second of these 2 strings is, much to your amazement, discarded!
This way of doing things makes it easy for you to count row_heading strings and their corresponding SQL columns, and makes it easy for me to cross-check your ability to count to 2.
Each other row contains a field in the 'current record'. The value in the first column comes from the row_headings parameter, and the value in the second column comes from the database.
The whole point of the exercise is to give you simple code for simple access to simple data.
See examples/test-clientdb.cgi for an example which will make all this clear.
tags the first row headings first column unit code second column the row the second headings parameter the current first row the sql row contains from the
Download DBIx::HTML::ClientDB 1.05
Other software in this category
- Desktop Environment
- Science and Engineering
- Text Editing&Processing