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
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
_perform_secondary_deletes, all of which do nothing by default.
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))
Determine if the action has been cancelled. Defaults to assuming the form is cancelled if the action parameter is set to cancel.
Returns the name of the primary key column, or index.
Returns the name of the primary table.
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".
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.
Format the error that occurs when there has been a database error during an insert command. The error itself is the argument.
Format the error that occurs when there has been a database error during an update command. The error itself is the argument.
Format the log entry that occurs when there has been a successful insert command.
Format the log entry that occurs when there has been a successful update command.
Format the log entry that occurs when the edited record cannot be deleted. The error is the argument.
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.
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.
Generic logger for the hook methods (below). Is the method called by the default hooks. Takes a hook hashref and an action scalar.
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.
Like the _deleted_hook above.
Like the _deleted_hook above.
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.
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
Barry King <firstname.lastname@example.org>
General-purpose HTML-embeddable perl object
Copyright 2002-2007 Wyrdwright, Inc. and licensed under the GNU GPL.
See LICENSE under the documentation for