Class: DB_Table
Source Location: /DB_Table-1.5.6/DB/Table.php
DB_Table_Base
|
--DB_Table
DB_Table is a database API and data type SQL abstraction class.
Author(s):
Version:
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
Method Detail
DB_Table (Constructor) [line 647]
object DB_Table DB_Table(
object
&$db, [string
$table = null], [mixed
$create = false])
|
|
Constructor. The constructor returns a DB_Table object that wraps an instance $db DB or MDB2, and that binds to a specific database table named $table. It can optionally create the database table or verify that its schema matches that declared in the $col and $idx parameters, depending on the value of the $create parameter. If there is an error on instantiation, $this->error will be populated with the PEAR_Error.
Parameters:
addFormElements [line 2065]
void addFormElements(
object
&$form, [array
$columns = null], [string
$array_name = null], [clientValidate
$clientValidate = null])
|
|
Adds elements and rules to a pre-existing HTML_QuickForm object. By default, the form will use the names of the columns as the names of the form elements. If you pass $array_name, the column names will become keys in an array named for this parameter.
Parameters:
addStaticFormElements [line 2088]
void addStaticFormElements(
object
&$form)
|
|
Adds static form elements like 'header', 'static', 'submit' or 'reset' to a pre-existing HTML_QuickForm object. The form elements needs to be defined in a property called $frm.
Parameters:
alter [line 1822]
Alters the table to match schema declared in $this->col and $this->idx. If the table does not exist, create it instead.
autoRecast [line 1492]
void autoRecast(
[bool
$flag = true])
|
|
Turns on (or off) automatic recasting of insert and update data. Turns on (if $flag is true) or off (if $flag is false) automatic forcible recasting of data to the declared data type, if required, prior to inserting or updating. The recasting is done by calling the DB_Table::recast() method from within the DB_Table::insert() and DB_Table::update().
Parameters:
autoValidInsert [line 1100]
void autoValidInsert(
[bool
$flag = true])
|
|
Turns on (or off) automatic validation of inserted data. Enables (if $flag is true) or disables (if $flag is false) automatic validation of data types prior to actual insertion into the database by the DB_Table::insert() method.
Parameters:
autoValidUpdate [line 1264]
void autoValidUpdate(
[bool
$flag = true])
|
|
Turns on (or off) automatic validation of updated data. Enables (if $flag is true) or disables (if $flag is false) automatic validation of data types prior to updating rows in the database by the update() method.
Parameters:
create [line 1752]
mixed create(
string
$flag)
|
|
Creates the table based on $this->col and $this->idx.
Parameters:
delete [line 1357]
mixed delete(
string
$where)
|
|
Deletes table rows matching a custom WHERE clause. Constructs and submits and SQL DELETE command with the specified WHERE clause. Command is submitted by DB::query() or MDB2::exec(). If a reference to a DB_Table_Database instance exists, carry out any ON DELETE actions declared in that instance before actual insertion, if emulation of ON DELETE actions is enabled in that instance.
Parameters:
getBlankRow [line 1465]
Returns a blank row array based on the column map. The array keys are the column names, and all values are set to null.
getColumns [line 844]
mixed getColumns(
[mixed
$col = null])
|
|
Returns all or part of the $this->col property array.
Parameters:
getForm [line 2030]
object HTML_QuickForm &getForm(
[array
$columns = null], [string
$array_name = null], [array
$args = array()], [string
$clientValidate = null], [array
$formFilters = null])
|
|
Creates and returns a QuickForm object based on table columns.
Parameters:
getFormElement [line 2140]
object HTML_QuickForm_Element &getFormElement(
string
$column, string
$elemname)
|
|
Creates and returns a single QuickForm element based on a DB_Table column name.
Parameters:
getFormElements [line 2166]
object HTML_QuickForm_Element &getFormElements(
array
$cols, [string
$array_name = null])
|
|
Creates and returns an array of QuickForm elements based on a DB_Table column name.
Parameters:
getFormGroup [line 2115]
array &getFormGroup(
[array
$columns = null], [string
$array_name = null])
|
|
Creates and returns an array of QuickForm elements based on an array of DB_Table column names.
Parameters:
getIndexes [line 892]
mixed getIndexes(
[mixed
$idx = null])
|
|
Returns all or part of the $this->idx property array.
Parameters:
insert [line 988]
mixed insert(
array
$data)
|
|
Inserts a single table row. Inserts data from associative array $data, in which keys are column names and values are column values. All required columns (except an auto-increment column) must be included in the data array. Columns values that are not set or null are inserted as SQL NULL values. If an auto-increment column is declared (by setting $this->auto_inc_col), and the value of that column in $data is not set or null, then a new sequence value will be generated and inserted. If auto-recasting is enabled (if $this->_auto_recast), the method will try, if necessary to recast $data to proper column types, with recast(). If auto-validation is enabled (if $this->_valid_insert), the method will validates column types with validInsert() before insertion.
Parameters:
isRequired [line 1972]
boolean isRequired(
mixed
$column)
|
|
Is a specific column required to be set and non-null?
Parameters:
isValid [line 1889]
boolean isValid(
array
$val, array
$col)
|
|
Checks if a value validates against the DB_Table data type for a given column. This only checks that it matches the data type; it does not do extended validation.
Parameters:
modeSupported [line 774]
bool modeSupported(
string
$mode, string
$phptype)
|
|
Is a creation mode supported for a RDBMS by DB_Table?
Parameters:
nextID [line 1400]
integer nextID(
[string
$seq_name = null])
|
|
Generates and returns a sequence value. Generates a sequence value by calling the DB or MDB2::nextID() method. The sequence name defaults to the table name, or may be specified explicitly.
Parameters:
quote [line 1445]
string quote(
mixed
$val)
|
|
Escapes and enquotes a value for use in an SQL query. Simple wrapper for DB_Common::quoteSmart() or MDB2::quote(), which returns the value of one of these functions. Helps makes user input safe against SQL injection attack.
Parameters:
recast [line 1522]
void recast(
array
&$data)
|
|
Forces array elements to the proper types for their columns. This will not valiate the data, and will forcibly change the data to match the recast-type. The date, time, and timestamp recasting has special logic for arrays coming from an HTML_QuickForm object so that the arrays are converted into properly-formatted strings.
Parameters:
setAutoInc [line 1079]
void setAutoInc(
[bool
$flag = true])
|
|
Turns on or off auto-incrementing of $auto_inc_col column (if any) For auto-incrementing to work, an $auto_inc_col column must be declared, auto-incrementing must be enabled (by this method), and the value of the $auto_inc_col column must be not set or null in the $data passed to the insert method.
Parameters:
setDatabaseInstance [line 944]
void setDatabaseInstance(
object
&$database)
|
|
Connect or disconnect a DB_Table_Database instance to this table instance. Used to re-connect this DB_Table object to a parent DB_Table_Database object during unserialization. Can also disconnect if the $database parameter is null. Use the DB_Table_Database::addTable method instead to add a table to a new DB_Table_Database.
Parameters:
setErrorMessage [line 820]
void setErrorMessage(
mixed
$code, [string
$message = null])
|
|
Overwrite one or more error messages, e.g. to internationalize them.
Overrides DB_Table_Base::setErrorMessage() (Overwrites one or more error messages, e.g., to internationalize them.)
Parameters:
supported [line 751]
bool supported(
string
$phptype, [string
$dbsyntax = ''])
|
|
Is a particular RDBMS supported by DB_Table?
Parameters:
toXML [line 2235]
string toXML(
[string
$indent = ''])
|
|
Returns XML string representation of the table
Parameters:
update [line 1204]
mixed update(
array
$data, string
$where)
|
|
Update table row or rows that match a custom WHERE clause Constructs and submits an SQL UPDATE command to update columns whose names are keys in the $data array parameter, in all rows that match the logical condition given by the $where string parameter. If auto-recasting is enabled (if $this->_auto_recast), update() will try, if necessary, to recast $data to proper column types, with recast(). If auto-validation is enabled (if $this->_valid_insert), update() validates column types with validUpdate() before insertion.
Parameters:
validInsert [line 1129]
boolean validInsert(
&$data, array
$data)
|
|
Validates an array for insertion into the table.
Parameters:
validUpdate [line 1293]
mixed validUpdate(
&$data, array
$data)
|
|
Validates an array for updating the table.
Parameters:
verify [line 1862]
Verifies the table based on $this->col and $this->idx.
_getFormColDefs [line 2188]
array _getFormColDefs(
[string|array
$column_set = null])
|
|
Creates a column definition array suitable for DB_Table_QuickForm.
Parameters:
Documentation generated on Mon, 11 Mar 2019 15:28:00 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|