NAME
DBIx::Browse::CGI - Perl extension to browse tables with a CGI interface.
SYNOPSIS
use DBIx::Browse::CGI;
my ($dbh, $dbb, $q);
$dbh = DBI->connect("DBI:Pg:dbname=enterprise")
or croak "Can't connect to database: $@";
$q = new CGI;
$dbb = new DBIx::Browse::CGI({
dbh => $dbh,
table => 'employee',
proper_fields => [ qw ( name fname ) ],
linked_fields => [ qw ( department category office ) ],
linked_tables => [ qw ( department category office ) ],
linked_values => [ qw ( name name phone ) ],
linked_refs => [ qw ( id id ide ) ],
aliases => [ qw ( name fname department category phone )],
primary_key => 'id',
cgi => $q
});
print
$q->start_html(
-title => "Test DBIx::Browse::CGI"
);
$dbb->list_form({
field_order => [ 1, 0, 4, 3, 2 ],
field_length => [ 14, 15, 15, 15, 10 ]
});
...etc
DESCRIPTION
The purpose of DBIx::Browse::CGI is to handle the browsing of relational tables with a human-like interface via Web.
DBIx::Browse::CGI transparently translates SELECTs, UPDATEs, DELETEs and INSERTs from the desired "human view" to the values needed for the table. This is the case when you have related tables (1 to n) where the detail table has a reference (FOREIGN KEY) to a generic table (i.e. Customers and Bills) with some index (tipically an integer).
METHODS
All the methods inherited from its parent class (DBIX::Browse(3)) plus the following:
- new
-
Creates a new DBIx::Browse::CGI object. The parameters are passed through a hash with the following added keys with respect to DBIx::Browse::new:
- cgi
-
A CGI object that will be used for Web interaction. If it is not defined a new CGI object will be created.
- max_rows
-
The maximum number of rows to be displayed per Web page (default: 10).
- max_flength
-
The maximum field length to be displayed (also the default for unknown field lengths).
- default_action
-
The default action (web page) that will be displayed if not set by the calling program (currently "List" or "Edit".
- form_params
-
A hash ref containing other form parameters that will appear as "HIDDEN" input fields.
- styles
-
An anonymous arrays of css styles ("CLASS") that will be applied to succesive rows of output.
- no_print
-
If set, the output methods (list_form, edit_form, and browse) will not print directly. Instead, they will return a string containig the output (in fact they always do). Otherwise they will print directly to standard output (default: 0).
- list_form
-
This method produces a CGI form suitable to explore the main table. It will list its rows in chunks of max_rows. It will present also the possibility to edit (see edit_form) any row and to filter the rows to display.
It takes one optional parameter with a hash reference with the following keys:
- field_names
-
An array reference containing the field names to be displayed.
- field_order
-
An array reference with the desired order index in wich the fields will appear.
- field_length
-
An array reference with the desired field length.
- edit_form
-
This method produces a CGI form suitable to browse the main table record by record. You can update, delete and insert new records.
It takes one optional parameter with a hash reference with the same structure than list_form.
- browse
-
This method will call list_form or edit_form as needed depending on the user input.
It takes one optional parameter with a hash reference with the same structure than list_form.
AUTHOR
Evilio José del Río Silván, edelrio@icm.csic.es
SEE ALSO
perl(1), DBI(3), CGI(3), DBIx::Browse(3).
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 860:
Non-ASCII character seen before =encoding in 'José'. Assuming CP1252