DBIx::HTML::ClientDB 1.05 review

Download
by rbytes.net on

DBIx::HTML::ClientDB is a Perl module to convert sql into a client-side db with keyed access. Synopsis use DBIx::HTML::

License: Perl Artistic License
File size: 11K
Developer: Ron Savage
0 stars award from rbytes.net

DBIx::HTML::ClientDB is a Perl module to convert sql into a client-side db with keyed access.

Synopsis

use DBIx::HTML::ClientDB;

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 -> javascript_for_client_db();
print $object -> table();
print $object -> javascript_for_client_init();

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:

First column

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.

Second column

The second column contains the 'current record' in the database.

Now for the rows:

First row

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.

Other rows

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 sum result is menu-driven access to the data returned by the SQL. All this is downloaded from your CGI script to the web client. Since changing the current menu item updates the other fields in this table using JavaScript, no message is sent to the web server, and hence you have maximum speed of access.

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.

Requirements:
Perl

DBIx::HTML::ClientDB 1.05 keywords