Abstract Class Zend_Db_Table_Abstract

Description

Class for SQL table interface.

  • copyright: Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  • abstract:
  • license: New BSD License

Located in /Db/Table/Abstract.php (line 47)


	
			
Direct descendents
Class Description
Abstract class Zend_Db_Table Class for SQL table interface.
Class Constant Summary
 ADAPTER = 'db'
 CASCADE = 'cascade'
 COLS = 'cols'
 COLUMNS = 'columns'
 DEPENDENT_TABLES = 'dependentTables'
 METADATA = 'metadata'
 METADATA_CACHE = 'metadataCache'
 NAME = 'name'
 ON_DELETE = 'onDelete'
 ON_UPDATE = 'onUpdate'
 PRIMARY = 'primary'
 REFERENCE_MAP = 'referenceMap'
 REF_COLUMNS = 'refColumns'
 REF_TABLE_CLASS = 'refTableClass'
 RESTRICT = 'restrict'
 ROWSET_CLASS = 'rowsetClass'
 ROW_CLASS = 'rowClass'
 SCHEMA = 'schema'
 SEQUENCE = 'sequence'
 SET_NULL = 'setNull'
Variable Summary
Method Summary
 static void setDefaultAdapter ([mixed $db = null])
 static void setDefaultMetadataCache ([mixed $metadataCache = null])
 static Zend_Cache_Core _setupMetadataCache (mixed $metadataCache)
 void __construct ([mixed $config = array()])
 Zend_Db_Table_Row_Abstract createRow ([ $data = array()])
 int delete (array|string $where)
 Zend_Db_Table_Rowset_Abstract fetchAll ([string|array|Zend_Db_Table_Select $where = null], [string|array $order = null], [int $count = null], [int $offset = null])
 Zend_Db_Table_Row_Abstract fetchRow ([string|array|Zend_Db_Table_Select $where = null], [string|array $order = null])
 array getReference (string $tableClassname, [string $ruleKey = null])
 string getRowClass ()
 string getRowsetClass ()
 mixed info ([$key $key = null])
 void init ()
 mixed insert ( $data)
 Zend_Db_Table_Abstract setRowClass (string $classname)
 Zend_Db_Table_Abstract setRowsetClass (string $classname)
 int update ( $data, array|string $where)
 int _cascadeDelete (string $parentTableClassname,  $primaryKey)
 int _cascadeUpdate (string $parentTableClassname,  $oldPrimaryKey,  $newPrimaryKey)
 array _fetch (Zend_Db_Table_Select $select)
 Zend_Db_Table_Select _order (Zend_Db_Table_Select $select, string|array $order)
 Zend_Db_Table_Abstract _setMetadataCache (mixed $metadataCache)
 Zend_Db_Table_Adapter_Abstract _setSequence (mixed $sequence)
 void _setup ()
 boolean _setupMetadata ()
 void _setupTableName ()
 Zend_Db_Table_Select _where (Zend_Db_Table_Select $select, string|array $where)
Variables
static Zend_Db_Adapter_Abstract $_defaultDb (line 78)

Default Zend_Db_Adapter_Abstract object.

  • access: protected
static Zend_Cache_Core $_defaultMetadataCache = null (line 85)

Default cache for information provided by the adapter's describeTable() method.

  • access: protected
array $_cols (line 113)

The table column names derived from Zend_Db_Adapter_Abstract::describeTable().

  • access: protected
Zend_Db_Adapter_Abstract $_db (line 92)

Zend_Db_Adapter_Abstract object.

  • access: protected
array $_dependentTables = array() (line 201)

Simple array of class names of tables that are "children" of the current table, in other words tables that contain a foreign key to this one.

Array elements are not table names; they are class names of classes that extend Zend_Db_Table_Abstract.

  • access: protected
integer $_identity = 1 (line 135)

If your primary key is a compound key, and one of the columns uses an auto-increment or sequence-generated value, set _identity to the ordinal index in the $_primary array for that column.

Note this index is the position of the column in the primary key, not the position of the column in the table. The primary key array is 1-based.

  • access: protected
array $_metadata = array() (line 150)

Information provided by the adapter's describeTable() method.

  • access: protected
Zend_Cache_Core $_metadataCache = null (line 157)

Cache for information provided by the adapter's describeTable() method.

  • access: protected
array $_name = null (line 106)

The table name.

  • access: protected
mixed $_primary = null (line 123)

The primary key column or columns.

A compound key should be declared as an array. You may declare a single-column primary key as a string.

  • access: protected
array $_referenceMap = array() (line 191)

Associative array map of declarative referential integrity rules.

This array has one entry per foreign key in the current table. Each key is a mnemonic name for one reference rule.

Each value is also an associative array, with the following keys:

  • columns = array of names of column(s) in the child table.
  • refTableClass = class name of the parent table.
  • refColumns = array of names of column(s) in the parent table, in the same order as those in the 'columns' entry.
  • onDelete = "cascade" means that a delete in the parent table also causes a delete of referencing rows in the child table.
  • onUpdate = "cascade" means that an update of primary key values in the parent table also causes an update of referencing rows in the child table.

  • access: protected
string $_rowClass = 'Zend_Db_Table_Row' (line 164)

Classname for row

  • access: protected
string $_rowsetClass = 'Zend_Db_Table_Rowset' (line 171)

Classname for rowset

  • access: protected
array $_schema = null (line 99)

The schema name (default null means current schema)

  • access: protected
mixed $_sequence = true (line 143)

Define the logic for new values in the primary key.

May be a string, boolean true, or boolean false.

  • access: protected
Methods
static getDefaultAdapter (line 386)

Gets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.

  • return: or null
  • access: public
static Zend_Db_Adapter_Abstract getDefaultAdapter ()
static getDefaultMetadataCache (line 450)

Gets the default metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().

  • return: or null
  • access: public
static Zend_Cache_Core getDefaultMetadataCache ()
static setDefaultAdapter (line 376)

Sets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.

  • access: public
static void setDefaultAdapter ([mixed $db = null])
  • mixed $db: Either an Adapter object, or a string naming a Registry key
static setDefaultMetadataCache (line 440)

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.

  • access: public
static void setDefaultMetadataCache ([mixed $metadataCache = null])
  • mixed $metadataCache: Either a Cache object, or a string naming a Registry key
static _setupAdapter (line 416)
  • throws: Zend_Db_Table_Exception
  • access: protected
static Zend_Db_Adapter_Abstract _setupAdapter (mixed $db)
  • mixed $db: Either an Adapter object, or a string naming a Registry key
static _setupMetadataCache (line 487)
  • throws: Zend_Db_Table_Exception
  • access: protected
static Zend_Cache_Core _setupMetadataCache (mixed $metadataCache)
  • mixed $metadataCache: Either a Cache object, or a string naming a Registry key
Constructor __construct (line 221)

Constructor.

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().

  • access: public
void __construct ([mixed $config = array()])
  • mixed $config: Array of user-specified config options, or just the Db Adapter.
createRow (line 1115)

Fetches a new blank row (not from the database).

  • access: public
Zend_Db_Table_Row_Abstract createRow ([ $data = array()])
  • array $data: OPTIONAL data to populate in the new row.
delete (line 896)

Deletes existing rows.

  • return: The number of rows deleted.
  • access: public
int delete (array|string $where)
  • array|string $where: SQL WHERE clause(s).
fetchAll (line 1018)

Fetches all rows.

Honors the Zend_Db_Adapter fetch mode.

  • return: The row results per the Zend_Db_Adapter fetch mode.
  • access: public
Zend_Db_Table_Rowset_Abstract fetchAll ([string|array|Zend_Db_Table_Select $where = null], [string|array $order = null], [int $count = null], [int $offset = null])
  • 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 (line 1104)

Fetches a new blank row (not from the database).

  • deprecated: since 0.9.3 - use createRow() instead.
  • access: public
fetchRow (line 1062)

Fetches one row in an object of type Zend_Db_Table_Row_Abstract, or returns Boolean false if no row matches the specified criteria.

  • return: The row results per the Zend_Db_Adapter fetch mode, or null if no row found.
  • access: public
Zend_Db_Table_Row_Abstract fetchRow ([string|array|Zend_Db_Table_Select $where = null], [string|array $order = null])
  • 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.
find (line 953)

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.

  • return: Row(s) matching the criteria.
  • throws: Zend_Db_Table_Exception
  • access: public
Zend_Db_Table_Rowset_Abstract find (mixed $key)
  • mixed $key: The value(s) of the primary keys.
getAdapter (line 406)

Gets the Zend_Db_Adapter_Abstract for this particular Zend_Db_Table object.

  • access: public
Zend_Db_Adapter_Abstract getAdapter ()
getDependentTables (line 365)
  • access: public
array getDependentTables ()
getMetadataCache (line 477)

Gets the metadata cache for information returned by Zend_Db_Adapter_Abstract::describeTable().

  • return: or null
  • access: public
Zend_Cache_Core getMetadataCache ()
getReference (line 327)
  • throws: Zend_Db_Table_Exception
  • access: public
array getReference (string $tableClassname, [string $ruleKey = null])
  • string $tableClassname
  • string $ruleKey: OPTIONAL
getRowClass (line 286)
  • access: public
string getRowClass ()
getRowsetClass (line 305)
  • access: public
string getRowsetClass ()
info (line 739)

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.

  • access: public
mixed info ([$key $key = null])
  • $key $key: The specific info part to return OPTIONAL
init (line 726)

Initialize object

Called from __construct() as final step of object instantiation.

  • access: public
void init ()
insert (line 783)

Inserts a new row.

  • return: The primary key of the row inserted.
  • access: public
mixed insert ( $data)
  • array $data: Column-value pairs.
select (line 771)

Returns an instance of a Zend_Db_Table_Select object.

  • access: public
setDependentTables (line 355)
  • return: Provides a fluent interface
  • access: public
Zend_Db_Table_Abstract setDependentTables ( $dependentTables)
  • array $dependentTables
setReferences (line 314)
  • return: Provides a fluent interface
  • access: public
Zend_Db_Table_Abstract setReferences ( $referenceMap)
  • array $referenceMap
setRowClass (line 276)
  • return: Provides a fluent interface
  • access: public
Zend_Db_Table_Abstract setRowClass (string $classname)
  • string $classname
setRowsetClass (line 295)
  • return: Provides a fluent interface
  • access: public
Zend_Db_Table_Abstract setRowsetClass (string $classname)
  • string $classname
update (line 846)

Updates existing rows.

  • return: The number of rows updated.
  • access: public
int update ( $data, array|string $where)
  • array $data: Column-value pairs.
  • array|string $where: An SQL WHERE clause, or an array of SQL WHERE clauses.
_cascadeDelete (line 909)

Called by parent table's class during delete() method.

  • return: Number of affected rows
  • access: public
int _cascadeDelete (string $parentTableClassname,  $primaryKey)
  • string $parentTableClassname
  • array $primaryKey
_cascadeUpdate (line 860)

Called by a row object for the parent table's class during save() method.

  • access: public
int _cascadeUpdate (string $parentTableClassname,  $oldPrimaryKey,  $newPrimaryKey)
  • string $parentTableClassname
  • array $oldPrimaryKey
  • array $newPrimaryKey
_fetch (line 1182)

Support method for fetching rows.

  • return: An array containing the row results in FETCH_ASSOC mode.
  • access: protected
array _fetch (Zend_Db_Table_Select $select)
_getReferenceMapNormalized (line 687)

Returns a normalized version of the reference map

  • access: protected
array _getReferenceMapNormalized ()
_order (line 1163)

Generate ORDER clause from user-supplied string or array

  • access: protected
Zend_Db_Table_Select _order (Zend_Db_Table_Select $select, string|array $order)
_setAdapter (line 395)
  • return: Provides a fluent interface
  • access: protected
Zend_Db_Table_Abstract _setAdapter (mixed $db)
  • mixed $db: Either an Adapter object, or a string naming a Registry key
_setMetadataCache (line 466)

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.

  • return: Provides a fluent interface
  • access: protected
Zend_Db_Table_Abstract _setMetadataCache (mixed $metadataCache)
  • mixed $metadataCache: Either a Cache object, or a string naming a Registry key
_setSequence (line 515)

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.

  • return: Provides a fluent interface
  • access: protected
Zend_Db_Table_Adapter_Abstract _setSequence (mixed $sequence)
  • mixed $sequence
_setup (line 529)

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.

  • access: protected
void _setup ()
_setupDatabaseAdapter (line 542)

Initialize database adapter.

  • access: protected
void _setupDatabaseAdapter ()
_setupMetadata (line 582)

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.

  • throws: Zend_Db_Table_Exception
  • access: protected
boolean _setupMetadata ()
_setupPrimaryKey (line 633)

Initialize primary key from metadata.

If $_primary is not defined, discover primary keys from the information returned by describeTable().

  • throws: Zend_Db_Table_Exception
  • access: protected
void _setupPrimaryKey ()
_setupTableName (line 564)

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.

  • access: protected
void _setupTableName ()
_where (line 1138)

Generate WHERE clause from user-supplied string or array

  • access: protected
Zend_Db_Table_Select _where (Zend_Db_Table_Select $select, string|array $where)
Class Constants
ADAPTER = 'db' (line 50)
CASCADE = 'cascade' (line 69)
COLS = 'cols' (line 54)
COLUMNS = 'columns' (line 63)
DEPENDENT_TABLES = 'dependentTables' (line 60)
METADATA = 'metadata' (line 55)
METADATA_CACHE = 'metadataCache' (line 56)
NAME = 'name' (line 52)
ON_DELETE = 'onDelete' (line 66)
ON_UPDATE = 'onUpdate' (line 67)
PRIMARY = 'primary' (line 53)
REFERENCE_MAP = 'referenceMap' (line 59)
REF_COLUMNS = 'refColumns' (line 65)
REF_TABLE_CLASS = 'refTableClass' (line 64)
RESTRICT = 'restrict' (line 70)
ROWSET_CLASS = 'rowsetClass' (line 58)
ROW_CLASS = 'rowClass' (line 57)
SCHEMA = 'schema' (line 51)
SEQUENCE = 'sequence' (line 61)
SET_NULL = 'setNull' (line 71)

Documentation generated on Mon, 28 Jul 2008 17:54:38 +0400 by phpDocumentor 1.4.1