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 license@zend.com 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()) : voidSupported 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().
Parameters| Name | Type | Description |
|---|
| $config | mixed | Array of user-specified config options, or just the Db Adapter. |
|---|



_cascadeDelete(string $parentTableClassname, array $primaryKey) : intCalled by parent table's class during delete() method.
Parameters| Name | Type | Description |
|---|
| $parentTableClassname | string | |
|---|
| $primaryKey | array | |
|---|
Returns| Type | Description |
|---|
| int | Number of affected rows |



_cascadeUpdate(string $parentTableClassname, array $oldPrimaryKey, array $newPrimaryKey) : intCalled by a row object for the parent table's class during save() method.
Parameters| Name | Type | Description |
|---|
| $parentTableClassname | string | |
|---|
| $oldPrimaryKey | array | |
|---|
| $newPrimaryKey | array | |
|---|
Returns 


_fetch(\Zend_Db_Table_Select $select) : arraySupport method for fetching rows.
ParametersReturns| Type | Description |
|---|
| array | An array containing the row results in FETCH_ASSOC mode. |



_order( $select, string | array $order) : \Zend_Db_Table_SelectGenerate ORDER clause from user-supplied string or array
Parameters| Name | Type | Description |
|---|
| $select | | |
|---|
| $order | string | array | OPTIONAL An SQL ORDER clause. |
|---|
Returns 


_setAdapter(mixed $db) : \Zend_Db_Table_AbstractParameters| Name | Type | Description |
|---|
| $db | mixed | Either an Adapter object, or a string naming a Registry key |
|---|
Returns 


_setMetadataCache(mixed $metadataCache) : \Zend_Db_Table_AbstractSets 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.
Parameters| Name | Type | Description |
|---|
| $metadataCache | mixed | Either a Cache object, or a string naming a Registry key |
|---|
Returns


_setSequence(mixed $sequence) : \Zend_Db_Table_Adapter_AbstractSets 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.
Parameters| Name | Type | Description |
|---|
| $sequence | mixed | |
|---|
Returns


_setup() : voidTurnkey 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_AbstractParameters| Name | Type | Description |
|---|
| $db | mixed | Either an Adapter object, or a string naming a Registry key |
|---|
ReturnsThrows 


_setupMetadataCache(mixed $metadataCache) : \Zend_Cache_CoreParameters| Name | Type | Description |
|---|
| $metadataCache | mixed | Either a Cache object, or a string naming a Registry key |
|---|
ReturnsThrows 


_setupPrimaryKey() : voidInitialize primary key from metadata.
If $_primary is not defined, discover primary keys
from the information returned by describeTable().
Throws


_setupTableName() : voidInitialize 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_SelectGenerate WHERE clause from user-supplied string or array
Parameters| Name | 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_AbstractAdd a reference to the reference map
Parameters| Name | 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_AbstractFetches a new blank row (not from the database).
Parameters| Name | 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) : intParameters| Name | Type | Description |
|---|
| $where | array | string | SQL WHERE clause(s). |
|---|
Returns| Type | 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_AbstractHonors the Zend_Db_Adapter fetch mode.
Parameters| Name | 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. |
|---|
Returns


fetchNew() : \Zend_Db_Table_Row_AbstractFetches 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 | nullFetches one row in an object of type Zend_Db_Table_Row_Abstract,
or returns null if no row matches the specified criteria.
Parameters| Name | 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_AbstractFetches 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.
ReturnsThrows


getReference(string $tableClassname, string $ruleKey = null) : arrayParameters| Name | Type | Description |
|---|
| $tableClassname | string | |
|---|
| $ruleKey | string | OPTIONAL |
|---|
ReturnsThrows 


info(string $key = null) : mixedReturns 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.
Parameters| Name | Type | Description |
|---|
| $key | string | The specific info part to return OPTIONAL |
|---|
ReturnsThrows


insert(array $data) : mixedParameters| Name | Type | Description |
|---|
| $data | array | Column-value pairs. |
|---|
Returns| Type | Description |
|---|
| mixed | The primary key of the row inserted. |



isIdentity(string $column) : booleanCheck if the provided column is an identity of the table
Parameters| Name | Type | Description |
|---|
| $column | string | |
|---|
ReturnsThrows 


select(bool $withFromPart = self::SELECT_WITHOUT_FROM_PART) : \Zend_Db_Table_SelectReturns an instance of a Zend_Db_Table_Select object.
Parameters| Name | Type | Description |
|---|
| $withFromPart | bool | Whether or not to include the from part of the select based on the table |
|---|
Returns 


setDefaultAdapter(mixed $db = null) : voidstaticSets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.
Parameters| Name | Type | Description |
|---|
| $db | mixed | Either an Adapter object, or a string naming a Registry key |
|---|



setDefaultMetadataCache(mixed $metadataCache = null) : voidstaticSets 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.
Parameters| Name | Type | Description |
|---|
| $metadataCache | mixed | Either a Cache object, or a string naming a Registry key |
|---|



setDefaultSource(string $defaultSource = self::DEFAULT_NONE) : \Zend_Db_Table_Abstractset the defaultSource property - this tells the table class where to find default values
Parameters| Name | Type | Description |
|---|
| $defaultSource | string | |
|---|
Returns 


setDefaultValues(array $defaultValues) : \Zend_Db_Table_Abstractset the default values for the table class
Parameters| Name | Type | Description |
|---|
| $defaultValues | array | |
|---|
Returns 


setDefinitionConfigName( $definitionConfigName) : \Zend_Db_Table_AbstractsetDefinitionConfigName()
Parameters| Name | Type | Description |
|---|
| $definitionConfigName | | |
|---|
Returns 


setMetadataCacheInClass(bool $flag) : \Zend_Db_Table_AbstractIndicate whether metadata should be cached in the class for the duration
of the instance
Parameters| Name | Type | Description |
|---|
| $flag | bool | |
|---|
Returns 


update(array $data, array | string $where) : intParameters| Name | Type | Description |
|---|
| $data | array | Column-value pairs. |
|---|
| $where | array | string | An SQL WHERE clause, or an array of SQL WHERE clauses. |
|---|
Returns| Type | Description |
|---|
| int | The number of rows updated. |