Class: db_form
Source Location: Program_Root/classes/general/db_form.php
Builds simple select, update and delete queries (on a single table), and uses the values stored to build form elements.
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
Class Methods
constructor db_form [line 84]
method clearAllValues [line 237]
Sets all the values as not sent from a form and clears
all the db values
method clearFormValues [line 248]
Sets all the values as not sent from a form
method executeSqlDelete [line 601]
boolean executeSqlDelete(
[boolean
$debug = false], [text
$logentry = ""], [text
$module = ""], [boolean
$sameop = true], [text
$operation = "DELETE"])
|
|
execute a SQL delete statement, meant to delete a single record.
How to use it: be sure that the primary key field(s) are setted before calling this function
Tags:
Parameters:
method executeSqlInsert [line 643]
boolean executeSqlInsert(
[boolean
$debug = false], [text
$logentry = ""], [text
$module = ""], [boolean
$sameop = true], [text
$operation = "INSERT"])
|
|
execute an insert statement
Tags:
Parameters:
method executeSqlUpdate [line 545]
boolean executeSqlUpdate(
[boolean
$debug = false], [text
$logentry = ""], [text
$module = ""], [boolean
$sameop = true], [text
$operation = "UPDATE"])
|
|
execute an update statement
Tags:
Parameters:
method fetch [line 193]
true fetch(
$id
$id, [mixed
$debug = false])
|
|
Fetches a record from db and fills internal status with it
Tags:
Parameters:
method getArraySelect [line 1067]
string getArraySelect(
mixed
$field, mixed
$option, [mixed
$attribute = array()])
|
|
gets a string to build a select form control. DEPRECATED This function builds a select form control trying to guess attributes from the db.
you can redefine any attribute you are not satisfied with or add new attributes with the $attribute associative array. The associative array $option used to build the must have two fields named "LABEL" and "VALUE"
method getAssocArray [line 361]
creates an index array with all the DB field names
Tags:
method getButton [line 983]
string getButton(
mixed
$field, mixed
$label, [mixed
$attribute = array()])
|
|
shows a button of type button
method getCheckbox [line 1169]
text getCheckbox(
text
$field, [text
$attribute = array()], [text
$label = ""])
|
|
Gets an html checkbox
Tags:
Parameters:
method getDateInput [line 1211]
string getDateInput(
mixed
$field, [mixed
$start_year = 1998], [mixed
$end_year = 0], [mixed
$attribute = array()])
|
|
gets a date input control with drop downs for day, month and year.
By default the start year is 1998, and the end year is the current year, but it can be changed by assigning $start_year and $end_year parameters. Month names are returned according to current locale.
method getDayInput [line 1233]
string getDayInput(
mixed
$field, [mixed
$attribute = array()])
|
|
Tags:
method getDbSelect [line 1026]
string getDbSelect(
mixed
$field, mixed
$query, [mixed
$attribute = array()], [mixed
$option = array()])
|
|
gets a string to build a select form control. DEPRECATED This function builds a select form control trying to guess attributes from the db.
the query used to build the must have two fields named "LABEL" and "VALUE" you can redefine any attribute you are not satisfied with or add new attributes with the $attribute associative array. you can add further options on top of db options with $option array
method getDbValue [line 757]
string getDbValue(
mixed
$field_name)
|
|
returns the value of the fetched field from the db or an empty string
Tags:
method getFieldArray [line 333]
creates an index array with all the DB field names
Tags:
method getFileInput [line 1197]
string getFileInput(
mixed
$field, [mixed
$attribute = array()])
|
|
gets a file input control
method getFormValue [line 775]
string getFormValue(
mixed
$field_name)
|
|
returns the value of the field in the sent and parsed form, or the value
setted with setFormValue, otherwise an empty string
Tags:
method getHidden [line 1186]
string getHidden(
mixed
$field, [mixed
$value = ""])
|
|
gets an hidden field
method getHtmlPopup [line 926]
void getHtmlPopup(
$field
$field, [$add_hidden
$add_hidden = true])
|
|
gets a string to be used as a html editor popup window.
The form containing it should have name="ewe" and id="ewe"
Parameters:
method getImage [line 997]
string getImage(
$field
$field, $src
$src, [$attribute
$attribute = array()])
|
|
shows an image submit button
Parameters:
method getInput [line 811]
void getInput(
string
$type, string
$field, array
$attribute, [string
$query = ""], [array
$extraoption = array()])
|
|
returns an html control according to $type parameter
Parameters:
method getInputTypesArray [line 845]
void getInputTypesArray(
)
|
|
gets an array with all supported input types in a format suitable for getSelect()
method getLogger [line 98]
Gets the logger object created by db_form
method getMbInsert [line 502]
Gets a Metabase insert. It's a piece of XML. Example:
<insert><field><name>id</name><value>2</value></field></insert>
method getMonthInput [line 1246]
string getMonthInput(
mixed
$field, [mixed
$attribute = array()])
|
|
Tags:
method getMultiSelect [line 1118]
string getMultiSelect(
mixed
$field, mixed
$option, mixed
$values, [mixed
$attribute = array()])
|
|
gets a string to build a multi select form control.
This function builds a select form control that allows multiple selections you can redefine any attribute you are not satisfied with or add new attributes with the $attribute associative array. the index array $option is an array of options, each of them is an array with value in position 0 and label in position 1. the index array $values contains the options which should be selected.
method getPasswordInput [line 953]
string getPasswordInput(
attribute
$field, [mixed
$attribute = array()])
|
|
gets a string to build a password input form control.
This function builds a text input form control trying to guess attributes. you can redefine any attribute you are not satisfied with or add new attributes with the $attribute associative array. example: $extra_html = array("maxlength" => 10, "size" => 12); The already setted attributes are the following: NAME - setted to $field_name VALUE - setted to the form value of this field, or to the db value if the form was not posted. If there isn't a db value too is setted to the empty string. maxlength - setted to the db field length
Parameters:
method getPrimaryKeys [line 476]
Get an array with the primary keys
Tags:
method getRadio [line 1148]
text getRadio(
text
$field, text
$value, [text
$label = ""], [text
$attribute = array()])
|
|
Gets a radio button
Tags:
Parameters:
method getSelect [line 1092]
string getSelect(
mixed
$field, mixed
$option, [mixed
$attribute = array()])
|
|
gets a string to build a select form control.
This function builds a select form control trying to guess attributes from the db. you can redefine any attribute you are not satisfied with or add new attributes with the $attribute associative array. the index array $option is an array of options, each of them is an array with value in position 0 and label in position 1.
method getSqlDelete [line 585]
returns a SQL statement to delete data according to the primary key value
method getSqlInsert [line 492]
Gets the sql insert statement
method getSqlUpdate [line 530]
returns a SQL statement to modify data according to form values
method getSubmit [line 972]
string getSubmit(
mixed
$field, mixed
$label, [mixed
$attribute = array()])
|
|
shows a submit button
method getTextArea [line 1009]
string getTextArea(
$attribute
$field, [mixed
$attribute = array()])
|
|
shows a text area fetching data from db
Parameters:
method getTextInput [line 886]
string getTextInput(
attribute
$field, [mixed
$attribute = array()])
|
|
gets a string to build a text input form control.
This function builds a text input form control trying to guess attributes. you can redefine any attribute you are not satisfied with or add new attributes with the $attribute associative array. Use upper case attribute names or they won't get recognized. example: $attribute = array("maxlength" => 10, "size" => 12); The already setted attributes are the following:
NAME - setted to $field_name
VALUE - setted to the form value of this field, or to the db value if the form
was not posted. If there isn't a db value too is setted to the empty string.
maxlength - setted to the db field length, can be changed with maxlength attribute
Parameters:
method getTextPopup [line 908]
void getTextPopup(
$field
$field, [$add_hidden
$add_hidden = true])
|
|
gets a string to be used as a text editor popup window.
The form containing it should have name="ewe" and id="ewe" db_form fields used are $field and $field."_type" for the text type. Allowed values are t/h for text and html.
Parameters:
method getValue [line 732]
string getValue(
mixed
$field)
|
|
returns the form value of the field if $field_name is a form field and
the form was sent and parsed, otherwise the db value if $field_name is a db field, otherwise the empty string
Tags:
method getValueArray [line 347]
creates an index array with the values for each database field
Tags:
method getValueForSql [line 677]
string getValueForSql(
mixed
$field)
|
|
Returns a field value, in the same way getValue does, but delimits
and escapes the field, as necessary to build the query
method getYearInput [line 1259]
string getYearInput(
mixed
$field, [mixed
$start_year = 1998], [mixed
$end_year = 0], [mixed
$attribute = array()])
|
|
Tags:
method isDB [line 1275]
boolean isDB(
mixed
$field_name)
|
|
Returns boolean whether the field is defined in the DB or not.
method isForm [line 1289]
boolean isForm(
mixed
$field_name)
|
|
Returns boolean whether the field is defined in the FORM or not.
method is_uploaded_file [line 184]
true is_uploaded_file(
mixed
$field_name)
|
|
Tests to see whether the $field_name was set from a valid file upload
Tags:
method newId [line 518]
finds a new id for the table and sets the primary key (primary key must be simple and numeric). returns the generated id The table must have a sequence.
Tags:
method parseForm [line 141]
parses the form and copies values into the _field array
method setDatadict [line 293]
void setDatadict(
mixed
$datadict)
|
|
Sets a custom data dictionary for a table not contained in tabledesc.
Example: 1 $dbf->setTable("page", "sl_", false); 2 $datadict = array(); 3 $datadict[] = array("name", "text", 32, true); 4 $datadict[] = array("id_module", "integer"); 5 $datadict[] = array("is_common", "boolean", 0, true); 6 $datadict[] = array("comment", "text", 255); 7 $dbf->setDatadict($datadict);
method setDBConnection [line 91]
void setDBConnection(
mixed
&$mb)
|
|
sets a reference to an already created Metabase DB object
method setDefaultAttrib [line 788]
void setDefaultAttrib(
mixed
$def_attrib)
|
|
Sets the default attributes for building a form control.
The attribute can be redefined in the form control and in this case the default value will be ignored
method setFormValue [line 797]
void setFormValue(
mixed
$field, mixed
$value)
|
|
allows to modify a value in the sent and parsed form or to set any value
as sent from a form
method setTable [line 114]
true setTable(
$table_name
$table_name, [$tprefix
$tprefix = ""], [$tabledesc
$tabledesc = true])
|
|
sets the table name to be used and reads meta data from db.
it's possible to reuse this object for more than one table.
Tags:
Parameters:
method setTableMetabase [line 130]
true setTableMetabase(
$table_name
$table_name, $tprefix
$tprefix, $meta
$meta)
|
|
sets the table name to be used and sets meta data from '$meta' it's possible to reuse this object for more than one table.
Tags:
Parameters:
method ucfields [line 411]
void ucfields(
mixed
$fields)
|
|
Applies ucwords to all fields listed in the array
method _getAttributeString [line 858]
void _getAttributeString(
mixed
&$res, mixed
$attribute)
|
|
Private function returning the attribute string from the attribute array
and the defaults attributes. If a value is defined in the attribute array it will have precedence over the default value
|
|