
Postgres::Handler::HTML - HTML Component for PostgreSQL data.

Accessors for PostgreSQL data. Simplifies data access through a series of standard class methods.

# Instantiate Object
#
use Postgres::Handler;
my $DB = Postgres::Handler->new(dbname=>'products',dbuser=>'postgres',dbpass=>'pgpassword');
# Retrieve Data & List Records
#
$DB->PrepLEX('SELECT * FROM products');
while ($item=$DB->GetRecord()) {
print "$item->{PROD_ID}\t$item->{PROD_TITLE}\t$item->{PROD_QTY}\n";
}
# Add / Update Record based on CGI Form
# assuming objCGI is an instatiated CGI object
# if the CGI param 'prod_id' is set we update
# if it is not set we add
#
my %cgimap;
foreach ('prod_id','prod_title','prod_qty') { $cgimap{$_} = $_; }
$DB->AddUpdate( CGI=>$objCGI , CGIKEY=>'prod_id',
TABLE=>'products', DBKEY=>'prod_id',
hrCGIMAP=>\%cgimap
);

#!/usr/bin/perl
#
# Connect to the postgres XYZ database owned by user1/mypass
# Set the primary key field for the abc table to the field named pkid
# Print the contents of the fldone field in the abc table where the pkid=123
#
use Postgres::Handler::HTML;
our $STORE = Postgres::Handler::HTML->new(dbname=>'xyz', dbuser=>'user1', dbpass=>'mypass');
$STORE->data('abc!PGHkeyfld'=>'pkid');
$STORE->ShowThe('abc!fldone',123);
exit(1);

Subclass of Postgres::Handler
Postgres::Handler
+- CGI::Carp
+- CGI::Util
+- Class::Struct
+- DBI

Produce an HTML Checkbox for the specified boolean field
Parameters
TABLE => name of table to get data from
CBNAME => name to put on the checkbox, defaults to VALUE
VALUE => field that contains the t/f use to set the checkmark
LABEL => what to put next to the checkbox as a label (defaults to field name)
KEY => value of the key used to lookup the data in the database
CHECKED => set to '1' to check by default if KEY not found
SCRIPT => script tags (or class tags) to add to checkbox HTML
NOLABEL => set to '1' to skip printing of label
Action
prints out the HTML Checkbox, checked if field is true
Return
0 = failure, sets error message, get with lasterror()
1 = success
Produce an HTML pulldown menu for the specified table/fields
Parameters
TABLE => name of table to get data from
PDNAME => name to put on the pulldown, defaults to VALUE
VALUE => which field we stick into the option values
SHOW => which field we spit out on the selection menu, defaults to VALUE
SELECT => mark the one with this VALUE as selected
ALLOWBLANK => set to 1 to allow blank selection (noted as ---)
ORDERBY => special ordering, defaults to SHOW field
WHERE => filtering selection clause (without WHERE, i.e. pdclass='class1')
SCRIPT => event script, such as 'onChange="DoSumthin();"'
PREADD => address to hashref of Add-ons for begining of list
key = the value
content = show
GROUP => group the data
Action
prints out the HTML pulldown
Produce an HTML Radio Button menu for the specified table/fields
Parameters
TABLE => name of table to get data from
RBNAME => name to put on the pulldown, defaults to VALUE
VALUE => which field we stick into the option values
SHOW => which field we spit out on the menu, defaults to VALUE
SELECT => mark the one with this VALUE as selected
ORDERBY => special ordering, defaults to SHOW field
WHERE => filtering selection clause (without WHERE, i.e. rbclass='class1')
Action
prints out the HTML Radio Buttons
Display header for retrieved records in an HTML <table> row One of these 2 id required DATAREF => reference to hash storing record DISPCOLS => reference to array of columns to show, defaults to hash key names Optional parameters FULLNAME => set to 1 to show full field name, otherwise we trunc up to first _ SORT => set to 1 to sort keys
Display retrieved records in an HTML <table> row
Parameters
DATAREF => reference to hash storing record (required)
DATAMODREF => reference to hash storing data modifiers
The field specified by the hash key is replaced
with the data specified in the value.
Use $Record{???} to place the record field ??? within
the substitution string.
If the modifier starts with ~eval(<blah>) then the modifier
evaluates <blah> and returns it's result. For example:
$datmodref{THISFIELD} = '~eval(substr($Record{FIELD},0,10))';
would display the first 10 characters of the field.
DISPLAYREF => reference to hash storing special cell formats for
each data element. Key = element, value = <td> modifier
DISPCOLS => reference to array of columns to show, defaults to hash key names
TRIMDATES => set to 'minute' or 'day' to trim date fields
date fields are any ending in 'LASTUPDATE'
WRAP => set to 1 to allow data wrapping
SORT => set to 1 to sort keys
ASFORM => set to 1 to show data as input form fields
NOTABLE => set to 1 to drop all table html tags
OUTPUT => output file handle
ROWMOD => modifier to <tr> row definition
CELLMOD => modifier to each <td> Cell definition
Set these CGI parameters to 0 if not defined. Used for checkbox form variables when we want to ensure the value is set to 0 (false) if they are not set via the CGI interface. HTML checkboxes are NOT passed to the CGI module if they are not checked, so this function helps us out by forcing the assumption that the CGI parameters passed here should be 0 if the are not received. Parameters [0] - the CGI variable [1] - an array of CGI parameters to be set Action Sets the named CGI parameters to 0 if they are not set, otherwise leaves the original value intact.
Load the DB record and spit out the value of the specified field
Parameters are positional.
Required
<0> field name to be displayed in "table!field" format
<1> key, lookup the record based on the Postgres::Handler key
that has been set for this field. Reference the
Postgres::Handler->Field method for more info.
Optional
[2] trim to this many characters

Cyber Sprocket Labs, Advanced Internet Technology Consultants Contact info@cybersprocket.com for more info.

Cyber Sprocket Labs (CSL) is and advanced internet technology consulting firm based in Charleston South Carolina. We provide custom software, database, and consulting services for small to mid-sized businesses. For more information, or to schedule a consult, visit our website at www.cybersprocket.com

Like the script and want to contribute? You can send payments via credit card or bank transfer using PayPal and sending money to our paypal@cybersprocket.com PayPal address.

(c) 2008, Cyber Sprocket Labs This script is covered by the GNU GENERAL PUBLIC LICENSE. View the license at http://www.gnu.org/copyleft/gpl.html

v1.0 - May 2008
Attach to Postgres::Handler via use base() construct
Cleaned up perldocs
Build new distro so we can do routine updates
v0.9 - January 2006
GROUP option on Pulldown()
Added some docs, minor code cleanup
v0.8 - September 2005
PREADD option on Pulldown()
v0.7 - August 2005
minor updates
v0.6 - Jun 13 2005
added script option to checkbox type
added no label option to checkbox type
v0.5 - Jun 09 2005
moved under Postgres::Handler:: namespace
initial CPAN release
v0.4 - Apr 28 2005
pod updates
Updated CheckBox() w/ default 'checked' option
Added ShowThe() method
v0.1 - Dec/2004
Initial private release