Class TDBForm

Description

Database-enabled TForm automatically loads and saves data

  • version: 10-15-2003 17:40
  • author: Greg MacLellan

Located in /dbform.inc.php (line 18)

TForm
   |
   --TDBForm
Variable Summary
mixed $debug
mixed $keyvalue
Method Summary
TDBForm TDBForm (string $name, TDatabaseAbstract &$db, string $table, string $keyfield, string $keyidvar, [array $conditions = array()], [string $idHandler = null])
Text confirmDelete ([string $class = ""])
void deleteEntry ()
True isEditing ()
void loadData ()
True prepareAndSave ()
True save ()
True saveData ()
void setMethod ([string $method = "POST"])
FORM_DELETE_NO wasConfirmedDelete ()
Variables
mixed $debug (line 21)

If the form is in debug mode (no queries will be performed).

  • access: public
mixed $keyvalue (line 34)

key id. Only useful after an INSERT

  • access: public

Inherited Variables

Inherited from TForm

TForm::$errors
TForm::$extraFields
TForm::$method
TForm::$name
TForm::$validated
Methods
Constructor TDBForm (line 73)

Create a new TDBForm. This loads and saves its data from a database.

All form object names must exist in the table.

TDBForm TDBForm (string $name, TDatabaseAbstract &$db, string $table, string $keyfield, string $keyidvar, [array $conditions = array()], [string $idHandler = null])
  • string $name: The name of the form
  • TDatabaseAbstract $db: A reference to a connected DatabaseAbstract object, connected to the database you're using.
  • string $table: The table to store/load data in
  • string $keyfield: Name of the keyfield to use to identify the row
  • string $keyidvar: The name of the variable containing the ID. This is used for both editing and used to propegate the ID in the form. If the value of this var is 0, then an INSERT instead of and UPDATE is performed.
  • array $conditions: Optionally a list of fieldnames (array keys) and values (array values) that have to be set for all table operations. For example, array("UserID"=>$UserID)
  • string $idHandler: Optionally the name of a function that will generate a new ID for the keyfield. This can be used to create custom or special ID numbers for new entries. It should accept one paramter, which will be an assoc. array containing the data about to be submitted, and it should return the ID to use, the same type as the keyfield. The returned value is checked in the db, and if it already exists, the function is called again until it makes a unique id.
confirmDelete (line 275)

Displays a Yes and No box asking the user to confirm deletion

  • return: to output
Text confirmDelete ([string $class = ""])
  • string $class: The class to use for the text boxes
deleteEntry (line 288)

Deletes the current entry from the table

  • private:
void deleteEntry ()
isEditing (line 296)

Checks if the form is currently being edited

  • return: if data exists and this is an edit, false if it's a new record
True isEditing ()
loadData (line 101)
void loadData ()
otherConditions (line 306)

Returns a string for the WHERE clause of sql containing a list of all the "other" conditions passed when the form was created.

  • return: string for the WHERE condition, starting with " AND "
A otherConditions ()
prepareAndSave (line 209)

Handler function for restoring all the values, and saving or deleting a form and etc

  • return: if the form was successfully saved or confirmed (or not) deleted
True prepareAndSave ()
save (line 231)

Handler function for saving or deleting (after confirmation) a form Should only be called in place of prepareAndSave() when doing processing manually.

  • return: if the form was successfully saved or confirmed (or not) deleted
True save ()
saveData (line 124)

Saves the current values into the database, Implicitly validates data

  • return: if the data was successfully saved
True saveData ()
setMethod (line 97)

Change the form submit method, to override the default of POST.

void setMethod ([string $method = "POST"])
  • string $method: The submit method to use for the form
wasConfirmedDelete (line 254)

Checks if the form was confirmed (either yes or no) for deletion

  • return: if the form was not confirmed, FORM_DELETE_CONF_YES if it was yes, FORM_DELETE_CONF_NO if it was no
  • private:
FORM_DELETE_NO wasConfirmedDelete ()

Inherited Methods

Inherited From TForm

TForm::TForm()
TForm::add()
TForm::getDefaultValues()
TForm::getmd5()
TForm::getNextLine()
TForm::getValue()
TForm::getValues()
TForm::html()
TForm::output()
TForm::restoreValues()
TForm::setError()
TForm::setValue()
TForm::validate()
TForm::wasSubmitted()

Documentation generated on Thu, 27 Nov 2003 14:58:52 -0500 by phpDocumentor 1.2.3