Zend Framework
1.12
|
Public Member Functions | |
__construct ($config=array()) | |
Constructor. | |
setOptions (Array $options) | |
setOptions() | |
setDefinition (Zend_Db_Table_Definition $definition) | |
setDefinition() | |
getDefinition () | |
getDefinition() | |
setDefinitionConfigName ($definitionConfigName) | |
setDefinitionConfigName() | |
getDefinitionConfigName () | |
getDefinitionConfigName() | |
setRowClass ($classname) | |
getRowClass () | |
setRowsetClass ($classname) | |
getRowsetClass () | |
addReference ($ruleKey, $columns, $refTableClass, $refColumns, $onDelete=null, $onUpdate=null) | |
Add a reference to the reference map. | |
setReferences (array $referenceMap) | |
getReference ($tableClassname, $ruleKey=null) | |
setDependentTables (array $dependentTables) | |
getDependentTables () | |
setDefaultSource ($defaultSource=self::DEFAULT_NONE) | |
set the defaultSource property - this tells the table class where to find default values | |
getDefaultSource () | |
returns the default source flag that determines where defaultSources come from | |
setDefaultValues (Array $defaultValues) | |
set the default values for the table class | |
getDefaultValues () | |
getAdapter () | |
Gets the Zend_Db_Adapter_Abstract for this particular Zend_Db_Table object. | |
getMetadataCache () | |
Gets the metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable(). | |
setMetadataCacheInClass ($flag) | |
Indicate whether metadata should be cached in the class for the duration of the instance. | |
metadataCacheInClass () | |
Retrieve flag indicating if metadata should be cached for duration of instance. | |
init () | |
Initialize object. | |
info ($key=null) | |
Returns table information. | |
select ($withFromPart=self::SELECT_WITHOUT_FROM_PART) | |
Returns an instance of a Zend_Db_Table_Select object. | |
insert (array $data) | |
Inserts a new row. | |
isIdentity ($column) | |
Check if the provided column is an identity of the table. | |
update (array $data, $where) | |
Updates existing rows. | |
_cascadeUpdate ($parentTableClassname, array $oldPrimaryKey, array $newPrimaryKey) | |
Called by a row object for the parent table's class during save() method. | |
delete ($where) | |
Deletes existing rows. | |
_cascadeDelete ($parentTableClassname, array $primaryKey) | |
Called by parent table's class during delete() method. | |
find () | |
Fetches rows by primary key. | |
fetchAll ($where=null, $order=null, $count=null, $offset=null) | |
Fetches all rows. | |
fetchRow ($where=null, $order=null, $offset=null) | |
Fetches one row in an object of type Zend_Db_Table_Row_Abstract, or returns null if no row matches the specified criteria. | |
fetchNew () | |
Fetches a new blank row (not from the database). | |
createRow (array $data=array(), $defaultSource=null) | |
Fetches a new blank row (not from the database). | |
Static Public Member Functions | |
static | setDefaultAdapter ($db=null) |
Sets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects. | |
static | getDefaultAdapter () |
Gets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects. | |
static | setDefaultMetadataCache ($metadataCache=null) |
Sets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable(). | |
static | getDefaultMetadataCache () |
Gets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable(). | |
static | getTableFromString ($tableName, Zend_Db_Table_Abstract $referenceTable=null) |
Public Attributes | |
const | ADAPTER = 'db' |
const | DEFINITION = 'definition' |
const | DEFINITION_CONFIG_NAME = 'definitionConfigName' |
const | SCHEMA = 'schema' |
const | NAME = 'name' |
const | PRIMARY = 'primary' |
const | COLS = 'cols' |
const | METADATA = 'metadata' |
const | METADATA_CACHE = 'metadataCache' |
const | METADATA_CACHE_IN_CLASS = 'metadataCacheInClass' |
const | ROW_CLASS = 'rowClass' |
const | ROWSET_CLASS = 'rowsetClass' |
const | REFERENCE_MAP = 'referenceMap' |
const | DEPENDENT_TABLES = 'dependentTables' |
const | SEQUENCE = 'sequence' |
const | COLUMNS = 'columns' |
const | REF_TABLE_CLASS = 'refTableClass' |
const | REF_COLUMNS = 'refColumns' |
const | ON_DELETE = 'onDelete' |
const | ON_UPDATE = 'onUpdate' |
const | CASCADE = 'cascade' |
const | CASCADE_RECURSE = 'cascadeRecurse' |
const | RESTRICT = 'restrict' |
const | SET_NULL = 'setNull' |
const | DEFAULT_NONE = 'defaultNone' |
const | DEFAULT_CLASS = 'defaultClass' |
const | DEFAULT_DB = 'defaultDb' |
const | SELECT_WITH_FROM_PART = true |
const | SELECT_WITHOUT_FROM_PART = false |
Protected Member Functions | |
_setAdapter ($db) | |
_setMetadataCache ($metadataCache) | |
Sets the metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable(). | |
_setSequence ($sequence) | |
Sets the sequence member, which defines the behavior for generating primary key values in new rows. | |
_setup () | |
Turnkey for initialization of a table object. | |
_setupDatabaseAdapter () | |
Initialize database adapter. | |
_setupTableName () | |
Initialize table and schema names. | |
_setupMetadata () | |
Initializes metadata. | |
_getCols () | |
Retrieve table columns. | |
_setupPrimaryKey () | |
Initialize primary key from metadata. | |
_getReferenceMapNormalized () | |
Returns a normalized version of the reference map. | |
_where (Zend_Db_Table_Select $select, $where) | |
Generate WHERE clause from user-supplied string or array. | |
_order (Zend_Db_Table_Select $select, $order) | |
Generate ORDER clause from user-supplied string or array. | |
_fetch (Zend_Db_Table_Select $select) | |
Support method for fetching rows. | |
Static Protected Member Functions | |
static | _setupAdapter ($db) |
static | _setupMetadataCache ($metadataCache) |
Protected Attributes | |
$_definition = null | |
$_definitionConfigName = null | |
$_db | |
$_schema = null | |
$_name = null | |
$_cols | |
$_primary = null | |
$_identity = 1 | |
$_sequence = true | |
$_metadata = array() | |
$_metadataCache = null | |
$_metadataCacheInClass = true | |
$_rowClass = 'Zend_Db_Table_Row' | |
$_rowsetClass = 'Zend_Db_Table_Rowset' | |
$_referenceMap = array() | |
$_dependentTables = array() | |
$_defaultSource = self::DEFAULT_NONE | |
$_defaultValues = array() | |
Static Protected Attributes | |
static | $_defaultDb |
static | $_defaultMetadataCache = null |
__construct | ( | $config = array() | ) |
Constructor.
Supported params for $config are:
mixed | $config | Array of user-specified config options, or just the Db Adapter. |
Allow a scalar argument to be the Adapter object or Registry key.
_cascadeDelete | ( | $parentTableClassname, | |
array | $primaryKey | ||
) |
Called by parent table's class during delete() method.
string | $parentTableClassname | |
array | $primaryKey |
Execute cascading deletes against dependent tables
_cascadeUpdate | ( | $parentTableClassname, | |
array | $oldPrimaryKey, | ||
array | $newPrimaryKey | ||
) |
Called by a row object for the parent table's class during save() method.
string | $parentTableClassname | |
array | $oldPrimaryKey | |
array | $newPrimaryKey |
|
protected |
Support method for fetching rows.
Zend_Db_Table_Select | $select | query options. |
|
protected |
Retrieve table columns.
|
protected |
Returns a normalized version of the reference map.
|
protected |
Generate ORDER clause from user-supplied string or array.
string | array | $order | OPTIONAL An SQL ORDER clause. |
|
protected |
mixed | $db | Either an Adapter object, or a string naming a Registry key |
|
protected |
Sets the metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
If $metadataCache is null, then no metadata cache is used. Since there is no opportunity to reload metadata after instantiation, this method need not be public, particularly because that it would have no effect results in unnecessary API complexity. To configure the metadata cache, use the metadataCache configuration option for the class constructor upon instantiation.
mixed | $metadataCache | Either a Cache object, or a string naming a Registry key |
|
protected |
Sets the sequence member, which defines the behavior for generating primary key values in new rows.
mixed | $sequence |
|
protected |
Turnkey for initialization of a table object.
Calls other protected methods for individual tasks, to make it easier for a subclass to override part of the setup logic.
|
staticprotected |
mixed | $db | Either an Adapter object, or a string naming a Registry key |
Zend_Db_Table_Exception |
|
protected |
|
protected |
Initializes metadata.
If metadata cannot be loaded from cache, adapter's describeTable() method is called to discover metadata information. Returns true if and only if the metadata are loaded from cache.
Zend_Db_Table_Exception |
|
staticprotected |
mixed | $metadataCache | Either a Cache object, or a string naming a Registry key |
Zend_Db_Table_Exception |
|
protected |
Initialize primary key from metadata.
If $_primary is not defined, discover primary keys from the information returned by describeTable().
Zend_Db_Table_Exception |
Special case for PostgreSQL: a SERIAL key implicitly uses a sequence object whose name is "<table>_<column>_seq".
|
protected |
Initialize table and schema names.
If the table name is not set in the class definition, use the class name itself as the table name.
A schema name provided with the table name (e.g., "schema.table") overrides any existing value for $this->_schema.
|
protected |
Generate WHERE clause from user-supplied string or array.
string | array | $where | OPTIONAL An SQL WHERE clause. |
addReference | ( | $ruleKey, | |
$columns, | |||
$refTableClass, | |||
$refColumns, | |||
$onDelete = null , |
|||
$onUpdate = null |
|||
) |
Add a reference to the reference map.
string | $ruleKey | |
string | array | $columns | |
string | $refTableClass | |
string | array | $refColumns | |
string | $onDelete | |
string | $onUpdate |
createRow | ( | array | $data = array() , |
$defaultSource = null |
|||
) |
Fetches a new blank row (not from the database).
array | $data | OPTIONAL data to populate in the new row. |
string | $defaultSource | OPTIONAL flag to force default values into new row |
delete | ( | $where | ) |
Deletes existing rows.
array | string | $where | SQL WHERE clause(s). |
Execute cascading deletes against dependent tables
fetchAll | ( | $where = null , |
|
$order = null , |
|||
$count = null , |
|||
$offset = null |
|||
) |
Fetches all rows.
Honors the Zend_Db_Adapter fetch mode.
string | array | Zend_Db_Table_Select | $where | OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object. |
string | array | $order | OPTIONAL An SQL ORDER clause. |
int | $count | OPTIONAL An SQL LIMIT count. |
int | $offset | OPTIONAL An SQL LIMIT offset. |
fetchNew | ( | ) |
Fetches a new blank row (not from the database).
fetchRow | ( | $where = null , |
|
$order = null , |
|||
$offset = null |
|||
) |
Fetches one row in an object of type Zend_Db_Table_Row_Abstract, or returns null if no row matches the specified criteria.
string | array | Zend_Db_Table_Select | $where | OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object. |
string | array | $order | OPTIONAL An SQL ORDER clause. |
int | $offset | OPTIONAL An SQL OFFSET value. |
find | ( | ) |
Fetches rows by primary key.
The argument specifies one or more primary key value(s). To find multiple rows by primary key, the argument must be an array.
This method accepts a variable number of arguments. If the table has a multi-column primary key, the number of arguments must be the same as the number of columns in the primary key. To find multiple rows in a table with a multi-column primary key, each argument must be an array with the same number of elements.
The find() method always returns a Rowset object, even if only one row was found.
mixed | $key | The value(s) of the primary keys. |
Zend_Db_Table_Exception |
getAdapter | ( | ) |
Gets the Zend_Db_Adapter_Abstract for this particular Zend_Db_Table object.
|
static |
Gets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.
|
static |
Gets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
getDefaultSource | ( | ) |
returns the default source flag that determines where defaultSources come from
getDefaultValues | ( | ) |
getDefinition | ( | ) |
getDefinitionConfigName | ( | ) |
getDependentTables | ( | ) |
getMetadataCache | ( | ) |
Gets the metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
getReference | ( | $tableClassname, | |
$ruleKey = null |
|||
) |
string | $tableClassname | |
string | $ruleKey | OPTIONAL |
Zend_Db_Table_Exception |
getRowClass | ( | ) |
getRowsetClass | ( | ) |
|
static |
info | ( | $key = null | ) |
Returns table information.
You can elect to return only a part of this information by supplying its key name, otherwise all information is returned as an array.
string | $key | The specific info part to return OPTIONAL |
Zend_Db_Table_Exception |
init | ( | ) |
insert | ( | array | $data | ) |
Inserts a new row.
array | $data | Column-value pairs. |
Zend_Db_Table assumes that if you have a compound primary key and one of the columns in the key uses a sequence, it's the _first_ column in the compound key.
If this table uses a database sequence object and the data does not specify a value, then get the next ID from the sequence and add it to the row. We assume that only the first column in a compound primary key takes a value from a sequence.
If the primary key can be generated automatically, and no value was specified in the user-supplied data, then omit it from the tuple.
Note: this checks for sensible values in the supplied primary key position of the data. The following values are considered empty: null, false, true, '', array()
INSERT the new row.
Fetch the most recent ID generated by an auto-increment or IDENTITY column, unless the user has specified a value, overriding the auto-increment mechanism.
Return the primary key value if the PK is a single column, else return an associative array of the PK column/value pairs.
isIdentity | ( | $column | ) |
Check if the provided column is an identity of the table.
string | $column |
Zend_Db_Table_Exception |
metadataCacheInClass | ( | ) |
Retrieve flag indicating if metadata should be cached for duration of instance.
select | ( | $withFromPart = self::SELECT_WITHOUT_FROM_PART | ) |
Returns an instance of a Zend_Db_Table_Select object.
bool | $withFromPart | Whether or not to include the from part of the select based on the table |
|
static |
Sets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.
mixed | $db | Either an Adapter object, or a string naming a Registry key |
|
static |
Sets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().
If $defaultMetadataCache is null, then no metadata cache is used by default.
mixed | $metadataCache | Either a Cache object, or a string naming a Registry key |
setDefaultSource | ( | $defaultSource = self::DEFAULT_NONE | ) |
set the defaultSource property - this tells the table class where to find default values
string | $defaultSource |
setDefaultValues | ( | Array | $defaultValues | ) |
set the default values for the table class
array | $defaultValues |
setDefinition | ( | Zend_Db_Table_Definition | $definition | ) |
setDefinitionConfigName | ( | $definitionConfigName | ) |
setDependentTables | ( | array | $dependentTables | ) |
array | $dependentTables |
setMetadataCacheInClass | ( | $flag | ) |
Indicate whether metadata should be cached in the class for the duration of the instance.
bool | $flag |
setOptions | ( | Array | $options | ) |
setReferences | ( | array | $referenceMap | ) |
array | $referenceMap |
setRowClass | ( | $classname | ) |
string | $classname |
setRowsetClass | ( | $classname | ) |
string | $classname |
update | ( | array | $data, |
$where | |||
) |
Updates existing rows.
array | $data | Column-value pairs. |
array | string | $where | An SQL WHERE clause, or an array of SQL WHERE clauses. |
|
protected |
|
protected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
const ADAPTER = 'db' |
const CASCADE = 'cascade' |
const CASCADE_RECURSE = 'cascadeRecurse' |
const COLS = 'cols' |
const COLUMNS = 'columns' |
const DEFAULT_CLASS = 'defaultClass' |
const DEFAULT_DB = 'defaultDb' |
const DEFAULT_NONE = 'defaultNone' |
const DEFINITION = 'definition' |
const DEFINITION_CONFIG_NAME = 'definitionConfigName' |
const DEPENDENT_TABLES = 'dependentTables' |
const METADATA = 'metadata' |
const METADATA_CACHE = 'metadataCache' |
const METADATA_CACHE_IN_CLASS = 'metadataCacheInClass' |
const NAME = 'name' |
const ON_DELETE = 'onDelete' |
const ON_UPDATE = 'onUpdate' |
const PRIMARY = 'primary' |
const REF_COLUMNS = 'refColumns' |
const REF_TABLE_CLASS = 'refTableClass' |
const REFERENCE_MAP = 'referenceMap' |
const RESTRICT = 'restrict' |
const ROW_CLASS = 'rowClass' |
const ROWSET_CLASS = 'rowsetClass' |
const SCHEMA = 'schema' |
const SELECT_WITH_FROM_PART = true |
const SELECT_WITHOUT_FROM_PART = false |
const SEQUENCE = 'sequence' |
const SET_NULL = 'setNull' |