Db/Table/Abstract.php
Zend Framework
LICENSE
This source file is subject to the new BSD license that is bundled
with this package in the file LICENSE.txt.
It is also available through the world-wide-web at this URL:
http://framework.zend.com/license/new-bsd
If you did not receive a copy of the license and are unable to
obtain it through the world-wide-web, please send an email
to
[email protected] so we can send you a copy immediately.
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
- Package
- Zend_Db
- Subpackage
- Table
- Version
- $Id$
\Zend_Db_Table_Abstract
Package: Zend_Db\TableClass for SQL table interface.
- Children
- \Zend_Session_SaveHandler_DbTable
- \Zend_Queue_Adapter_Db_Queue
- \Zend_Queue_Adapter_Db_Message
- \Zend_Db_Table
- Category
- Zend
- Copyright
- Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
- License
- New BSD License
Constants
Properties
Methods
__construct(mixed $config = array()) : void
Supported params for $config are:
- db = user-supplied instance of database connector,
or key name of registry instance.
- name = table name.
- primary = string or array of primary key(s).
- rowClass = row class name.
- rowsetClass = rowset class name.
- referenceMap = array structure to declare relationship
to parent tables.
- dependentTables = array of child tables.
- metadataCache = cache for information from adapter describeTable().
ParametersName | Type | Description |
---|
$config | mixed | Array of user-specified config options, or just the Db Adapter. |
---|
_cascadeDelete(string $parentTableClassname, array $primaryKey) : int
Called by parent table's class during delete() method.
ParametersName | Type | Description |
---|
$parentTableClassname | string | |
---|
$primaryKey | array | |
---|
ReturnsType | Description |
---|
int | Number of affected rows |
_cascadeUpdate(string $parentTableClassname, array $oldPrimaryKey, array $newPrimaryKey) : int
Called by a row object for the parent table's class during save() method.
ParametersName | Type | Description |
---|
$parentTableClassname | string | |
---|
$oldPrimaryKey | array | |
---|
$newPrimaryKey | array | |
---|
Returns _fetch(\Zend_Db_Table_Select $select) : array
Support method for fetching rows.
ParametersReturnsType | Description |
---|
array | An array containing the row results in FETCH_ASSOC mode. |
_order( $select, string | array $order) : \Zend_Db_Table_Select
Generate ORDER clause from user-supplied string or array
ParametersName | Type | Description |
---|
$select | | |
---|
$order | string | array | OPTIONAL An SQL ORDER clause. |
---|
Returns _setAdapter(mixed $db) : \Zend_Db_Table_Abstract
ParametersName | Type | Description |
---|
$db | mixed | Either an Adapter object, or a string naming a Registry key |
---|
Returns _setMetadataCache(mixed $metadataCache) : \Zend_Db_Table_Abstract
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.
ParametersName | Type | Description |
---|
$metadataCache | mixed | Either a Cache object, or a string naming a Registry key |
---|
Returns_setSequence(mixed $sequence) : \Zend_Db_Table_Adapter_Abstract
Sets the sequence member, which defines the behavior for generating
primary key values in new rows.
- If this is a string, then the string names the sequence object.
- If this is boolean true, then the key uses an auto-incrementing
or identity mechanism.
- If this is boolean false, then the key is user-defined.
Use this for natural keys, for example.
ParametersName | Type | Description |
---|
$sequence | mixed | |
---|
Returns_setup() : void
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.
_setupAdapter(mixed $db) : \Zend_Db_Adapter_Abstract
ParametersName | Type | Description |
---|
$db | mixed | Either an Adapter object, or a string naming a Registry key |
---|
ReturnsThrows _setupMetadataCache(mixed $metadataCache) : \Zend_Cache_Core
ParametersName | Type | Description |
---|
$metadataCache | mixed | Either a Cache object, or a string naming a Registry key |
---|
ReturnsThrows _setupPrimaryKey() : void
Initialize primary key from metadata.
If $_primary is not defined, discover primary keys
from the information returned by describeTable().
Throws_setupTableName() : void
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.
_where( $select, string | array $where) : \Zend_Db_Table_Select
Generate WHERE clause from user-supplied string or array
ParametersName | Type | Description |
---|
$select | | |
---|
$where | string | array | OPTIONAL An SQL WHERE clause. |
---|
Returns addReference(string $ruleKey, string | array $columns, string $refTableClass, string | array $refColumns, string $onDelete = null, string $onUpdate = null) : \Zend_Db_Table_Abstract
Add a reference to the reference map
ParametersName | Type | Description |
---|
$ruleKey | string | |
---|
$columns | string | array | |
---|
$refTableClass | string | |
---|
$refColumns | string | array | |
---|
$onDelete | string | |
---|
$onUpdate | string | |
---|
Returns createRow(array $data = array(), string $defaultSource = null) : \Zend_Db_Table_Row_Abstract
Fetches a new blank row (not from the database).
ParametersName | Type | Description |
---|
$data | array | OPTIONAL data to populate in the new row. |
---|
$defaultSource | string | OPTIONAL flag to force default values into new row |
---|
Returns delete(array | string $where) : int
ParametersName | Type | Description |
---|
$where | array | string | SQL WHERE clause(s). |
---|
ReturnsType | Description |
---|
int | The number of rows deleted. |
fetchAll(string | array | \Zend_Db_Table_Select $where = null, string | array $order = null, int $count = null, int $offset = null) : \Zend_Db_Table_Rowset_Abstract
Honors the Zend_Db_Adapter fetch mode.
ParametersName | Type | Description |
---|
$where | string | array | \Zend_Db_Table_Select | OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object. |
---|
$order | string | array | OPTIONAL An SQL ORDER clause. |
---|
$count | int | OPTIONAL An SQL LIMIT count. |
---|
$offset | int | OPTIONAL An SQL LIMIT offset. |
---|
ReturnsfetchNew() : \Zend_Db_Table_Row_Abstract
Fetches a new blank row (not from the database).
ReturnsDetails- Deprecated
- since 0.9.3 - use createRow() instead.
fetchRow(string | array | \Zend_Db_Table_Select $where = null, string | array $order = null, int $offset = null) : \Zend_Db_Table_Row_Abstract | null
Fetches one row in an object of type Zend_Db_Table_Row_Abstract,
or returns null if no row matches the specified criteria.
ParametersName | Type | Description |
---|
$where | string | array | \Zend_Db_Table_Select | OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object. |
---|
$order | string | array | OPTIONAL An SQL ORDER clause. |
---|
$offset | int | OPTIONAL An SQL OFFSET value. |
---|
Returns find() : \Zend_Db_Table_Rowset_Abstract
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.
ReturnsThrowsgetReference(string $tableClassname, string $ruleKey = null) : array
ParametersName | Type | Description |
---|
$tableClassname | string | |
---|
$ruleKey | string | OPTIONAL |
---|
ReturnsThrows info(string $key = null) : mixed
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.
ParametersName | Type | Description |
---|
$key | string | The specific info part to return OPTIONAL |
---|
ReturnsThrowsinsert(array $data) : mixed
ParametersName | Type | Description |
---|
$data | array | Column-value pairs. |
---|
ReturnsType | Description |
---|
mixed | The primary key of the row inserted. |
isIdentity(string $column) : boolean
Check if the provided column is an identity of the table
ParametersName | Type | Description |
---|
$column | string | |
---|
ReturnsThrows select(bool $withFromPart = self::SELECT_WITHOUT_FROM_PART) : \Zend_Db_Table_Select
Returns an instance of a Zend_Db_Table_Select object.
ParametersName | Type | Description |
---|
$withFromPart | bool | Whether or not to include the from part of the select based on the table |
---|
Returns setDefaultAdapter(mixed $db = null) : void
staticSets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.
ParametersName | Type | Description |
---|
$db | mixed | Either an Adapter object, or a string naming a Registry key |
---|
setDefaultMetadataCache(mixed $metadataCache = null) : void
staticSets 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.
ParametersName | Type | Description |
---|
$metadataCache | mixed | Either a Cache object, or a string naming a Registry key |
---|
setDefaultSource(string $defaultSource = self::DEFAULT_NONE) : \Zend_Db_Table_Abstract
set the defaultSource property - this tells the table class where to find default values
ParametersName | Type | Description |
---|
$defaultSource | string | |
---|
Returns setDefaultValues(array $defaultValues) : \Zend_Db_Table_Abstract
set the default values for the table class
ParametersName | Type | Description |
---|
$defaultValues | array | |
---|
Returns setDefinitionConfigName( $definitionConfigName) : \Zend_Db_Table_Abstract
setDefinitionConfigName()
ParametersName | Type | Description |
---|
$definitionConfigName | | |
---|
Returns setMetadataCacheInClass(bool $flag) : \Zend_Db_Table_Abstract
Indicate whether metadata should be cached in the class for the duration
of the instance
ParametersName | Type | Description |
---|
$flag | bool | |
---|
Returns update(array $data, array | string $where) : int
ParametersName | Type | Description |
---|
$data | array | Column-value pairs. |
---|
$where | array | string | An SQL WHERE clause, or an array of SQL WHERE clauses. |
---|
ReturnsType | Description |
---|
int | The number of rows updated. |