Apache::Wyrd::SQLForm - General Form Wyrd for editing data in SQL
<BASENAME::SQLForm index="user_id" table="users"> <BASENAME::Form::Template name="password"> <BASENAME::Form::Preload> <BASENAME::Defaults> select 'root' as user_id; </BASENAME::Defaults> <BASENAME::Query> select user_id from users where name='Groucho' </BASENAME::Query> </BASENAME::Form::Preload> <b>Enter Password:</b><br> <BASENAME::Input name="password" type="password" /> <BASENAME::Input name="user_id" type="hidden" /> </BASENAME::Form::Template> <BASENAME::Form::Template name="result"> <H1>Status: $:_status</H1> <HR> <P>$:_message</P> </BASENAME::Form::Template> </BASENAME::SQLForm>
The SQLForm is a subclass of Apache::Wyrd::Form. It is meant to simplify the creation of forms that are used to edit data within a database connected to via the Apache::Wyrd::DBL.
Apache::Wyrd::DBL
The SQLForm makes the assumption that there is a primary table on which the edit is operating and that other tables will, if necessary, have elements inserted, changed or deleted from them as they relate to the primary table.
This module is meant to be subclassed, so a large number of its methods are only defined in order to be overridden. Any changes to secondary tables, for example, need to be handled by subclassing _prep_secondary, _submit_secondary, and _perform_secondary_deletes, all of which do nothing by default.
_prep_secondary
_submit_secondary
_perform_secondary_deletes
The index column of the primary table, i.e. the name of the primary key column.
The name of the primary table.
(format: (returns) name (arguments after self))
cancelled
Determine if the action has been cancelled. Defaults to assuming the form is cancelled if the action parameter is set to cancel.
index
Returns the name of the primary key column, or index.
table
Returns the name of the primary table.
default_ok
Returns the word used to describe the status of OK. Default is literal "OK".
Returns the word used to describe the status of not OK. Default is literal "Error".
default_log
Initializes the log of SQL transactions which took place during the submission. The idea is that each SQL query or command will produce results, and these results will be fed back to the user as a log. Defaults to undef.
default_insert_error
Format the error that occurs when there has been a database error during an insert command. The error itself is the argument.
default_update_error
Format the error that occurs when there has been a database error during an update command. The error itself is the argument.
default_insert_ok
Format the log entry that occurs when there has been a successful insert command.
default_update_ok
Format the log entry that occurs when there has been a successful update command.
primary_delete_error
Format the log entry that occurs when the edited record cannot be deleted. The error is the argument.
deleted
Checks to see if the action CGI parameter is set to "really_delete", and if so, deletes the record from the primary table and calls the _perform_secondary_deletes method to remove associated records in secondary tables. Returns a 1 if the deletion occurred, undef otherwise.
_prep_submission
Hook method for preparing the data submission. Performed prior to submitting, but after a check for deletions. Does nothing by default.
Hook method for preparing the secondary data. Called prior to _submit_secondary. Does nothing by default.
Hook method for performing alterations on tables other than the primary one. Does nothing by default.
Hook method for removing records associated with the primary record. Does nothing by default.
_logger_hook
Generic logger for the hook methods (below). Is the method called by the default hooks. Takes a hook hashref and an action scalar.
_deleted_hook
Backend hook. Allows a secondary device to be notified that a deletion, addition, or update has occurred. Takes the argument of a hashref in the same format as Apache::Wyrd::Services::SAK::_exists_in_table. By default only logs the event in the _info log via the _logger_hook above.
_added_hook
Like the _deleted_hook above.
_updated_hook
_sets
_join_sets
_split_sets
Hook methods for dealing with data which may arrive from CGI as an array, but is submitted in the form of a comma-joined set of values. These are usually data in a SET or ENUM column within an SQL database table.
List all columns to be treated as sets. The CGI param of this name will be manipulated to convert to and from arrays in order to translate between SQL and CGI.
depending how sets data types are treated in your DBA, use this method for splitting the set value into an arrayref of the values of the set. The default is to split the sets by comma.
the opposite of _split_sets. How to turn an arrayref of values into a value acceptable by your DBA. By default, joins the values with a comma.
_set_feedback
Allow globals to be set for the feedback page. Called as a last step after all the data has been submitted.
Reserves the _submit_data method above and beyond the methods already reserved by Apache::Wyrd::Form. Also overrides the Form methods _prep_preloads and _check_form.
Apache::Wyrd::Form
_prep_preloads
_check_form
Barry King <wyrd@nospam.wyrdwright.com>
General-purpose HTML-embeddable perl object
Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for Apache::Wyrd.
Apache::Wyrd
To install Apache::Wyrd, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Apache::Wyrd
CPAN shell
perl -MCPAN -e shell install Apache::Wyrd
For more information on module installation, please visit the detailed CPAN module installation guide.