Class for SQL table interface.

category Zend
package Zend_Queue
subpackage Adapter
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Db_Table_Abstract

 Methods

Constructor.

__construct(mixed $config = array()) : void
Inherited

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

Parameters

$config

mixed

Array of user-specified config options, or just the Db Adapter.

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

_cascadeDelete(string $parentTableClassname, array $primaryKey) : integer
Inherited

Parameters

$parentTableClassname

string

$primaryKey

array

Returns

integerNumber of affected rows

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

_cascadeUpdate(string $parentTableClassname, array $oldPrimaryKey, array $newPrimaryKey) : integer
Inherited

Parameters

$parentTableClassname

string

$oldPrimaryKey

array

$newPrimaryKey

array

Returns

integer

Add a reference to the reference map

addReference(string $ruleKey, string|array $columns, string $refTableClass, string|array $refColumns, string $onDelete = null, string $onUpdate = null) : \Zend_Db_Table_Abstract
Inherited

Parameters

$ruleKey

string

$columns

stringarray

$refTableClass

string

$refColumns

stringarray

$onDelete

string

$onUpdate

string

Returns

\Zend_Db_Table_Abstract

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

createRow(array $data = array(), string $defaultSource = null) : \Zend_Db_Table_Row_Abstract
Inherited

Parameters

$data

array

OPTIONAL data to populate in the new row.

$defaultSource

string

OPTIONAL flag to force default values into new row

Returns

\Zend_Db_Table_Row_Abstract

Deletes existing rows.

delete(array|string $where) : integer
Inherited

Parameters

$where

arraystring

SQL WHERE clause(s).

Returns

integerThe number of rows deleted.

Fetches all rows.

fetchAll(string|array|\Zend_Db_Table_Select $where = null, string|array $order = null, integer $count = null, integer $offset = null) : \Zend_Db_Table_Rowset_Abstract
Inherited

Honors the Zend_Db_Adapter fetch mode.

Parameters

$where

stringarray\Zend_Db_Table_Select

OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.

$order

stringarray

OPTIONAL An SQL ORDER clause.

$count

integer

OPTIONAL An SQL LIMIT count.

$offset

integer

OPTIONAL An SQL LIMIT offset.

Returns

\Zend_Db_Table_Rowset_AbstractThe row results per the Zend_Db_Adapter fetch mode.

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

fetchNew() : \Zend_Db_Table_Row_Abstract
Inherited
deprecated since 0.9.3 - use createRow() instead.

Returns

\Zend_Db_Table_Row_Abstract

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

fetchRow(string|array|\Zend_Db_Table_Select $where = null, string|array $order = null, integer $offset = null) : \Zend_Db_Table_Row_Abstract | null
Inherited

Parameters

$where

stringarray\Zend_Db_Table_Select

OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.

$order

stringarray

OPTIONAL An SQL ORDER clause.

$offset

integer

OPTIONAL An SQL OFFSET value.

Returns

\Zend_Db_Table_Row_AbstractnullThe row results per the Zend_Db_Adapter fetch mode, or null if no row found.

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.

find() : \Zend_Db_Table_Rowset_Abstract
Inherited

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.

Exceptions

\Zend_Db_Table_Exception

Returns

\Zend_Db_Table_Rowset_AbstractRow(s) matching the criteria.

Gets the Zend_Db_Adapter_Abstract for this particular Zend_Db_Table object.

getAdapter() : \Zend_Db_Adapter_Abstract
Inherited

Returns

\Zend_Db_Adapter_Abstract

Gets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.

getDefaultAdapter() : \Zend_Db_Adapter_Abstract
InheritedStatic

Returns

\Zend_Db_Adapter_Abstractor null

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

getDefaultMetadataCache() : \Zend_Cache_Core
InheritedStatic

Returns

\Zend_Cache_Coreor null

returns the default source flag that determines where defaultSources come from

getDefaultSource() : \unknown
Inherited

Returns

\unknown

getDefaultValues()

getDefaultValues() 
Inherited

getDefinition()

getDefinition() : \Zend_Db_Table_Definition | null
Inherited

Returns

\Zend_Db_Table_Definitionnull

getDefinitionConfigName()

getDefinitionConfigName() : string
Inherited

Returns

string

getDependentTables()

getDependentTables() : array
Inherited

Returns

array

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

getMetadataCache() : \Zend_Cache_Core
Inherited

Returns

\Zend_Cache_Coreor null

getReference()

getReference(string $tableClassname, string $ruleKey = null) : array
Inherited

Parameters

$tableClassname

string

$ruleKey

string

OPTIONAL

Exceptions

\Zend_Db_Table_Exception

Returns

array

getRowClass()

getRowClass() : string
Inherited

Returns

string

getRowsetClass()

getRowsetClass() : string
Inherited

Returns

string

Get table gateway object from string

getTableFromString(string $tableName, \Zend_Db_Table_Abstract $referenceTable = null) : \Zend_Db_Table_Abstract
InheritedStatic

Parameters

$tableName

string

$referenceTable

\Zend_Db_Table_Abstract

Exceptions

\Zend_Db_Table_Row_Exception

Returns

\Zend_Db_Table_Abstract

Returns table information.

info(string $key = null) : mixed
Inherited

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

$key

string

The specific info part to return OPTIONAL

Exceptions

\Zend_Db_Table_Exception

Returns

mixed

Initialize object

init() : void
Inherited

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

Inserts a new row.

insert(array $data) : mixed
Inherited

Parameters

$data

array

Column-value pairs.

Returns

mixedThe primary key of the row inserted.

Check if the provided column is an identity of the table

isIdentity(string $column) : boolean
Inherited

Parameters

$column

string

Exceptions

\Zend_Db_Table_Exception

Returns

boolean

Retrieve flag indicating if metadata should be cached for duration of instance

metadataCacheInClass() : boolean
Inherited

Returns

boolean

Returns an instance of a Zend_Db_Table_Select object.

select(boolean $withFromPart = self::SELECT_WITHOUT_FROM_PART) : \Zend_Db_Table_Select
Inherited

Parameters

$withFromPart

boolean

Whether or not to include the from part of the select based on the table

Returns

\Zend_Db_Table_Select

Sets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.

setDefaultAdapter(mixed $db = null) : void
InheritedStatic

Parameters

$db

mixed

Either an Adapter object, or a string naming a Registry key

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

setDefaultMetadataCache(mixed $metadataCache = null) : void
InheritedStatic

If $defaultMetadataCache is null, then no metadata cache is used by default.

Parameters

$metadataCache

mixed

Either a Cache object, or a string naming a Registry key

set the defaultSource property - this tells the table class where to find default values

setDefaultSource(string $defaultSource = self::DEFAULT_NONE) : \Zend_Db_Table_Abstract
Inherited

Parameters

$defaultSource

string

Returns

\Zend_Db_Table_Abstract

set the default values for the table class

setDefaultValues(array $defaultValues) : \Zend_Db_Table_Abstract
Inherited

Parameters

$defaultValues

array

Returns

\Zend_Db_Table_Abstract

setDefinition()

setDefinition(\Zend_Db_Table_Definition $definition) : \Zend_Db_Table_Abstract
Inherited

Parameters

$definition

\Zend_Db_Table_Definition

Returns

\Zend_Db_Table_Abstract

setDefinitionConfigName()

setDefinitionConfigName($definitionConfigName) : \Zend_Db_Table_Abstract
Inherited

Parameters

$definitionConfigName

Returns

\Zend_Db_Table_Abstract

setDependentTables()

setDependentTables(array $dependentTables) : \Zend_Db_Table_Abstract
Inherited

Parameters

$dependentTables

array

Returns

\Zend_Db_Table_AbstractProvides a fluent interface

Indicate whether metadata should be cached in the class for the duration of the instance

setMetadataCacheInClass(boolean $flag) : \Zend_Db_Table_Abstract
Inherited

Parameters

$flag

boolean

Returns

\Zend_Db_Table_Abstract

setOptions()

setOptions(array $options) : \Zend_Db_Table_Abstract
Inherited

Parameters

$options

array

Returns

\Zend_Db_Table_Abstract

setReferences()

setReferences(array $referenceMap) : \Zend_Db_Table_Abstract
Inherited

Parameters

$referenceMap

array

Returns

\Zend_Db_Table_AbstractProvides a fluent interface

setRowClass()

setRowClass(string $classname) : \Zend_Db_Table_Abstract
Inherited

Parameters

$classname

string

Returns

\Zend_Db_Table_AbstractProvides a fluent interface

setRowsetClass()

setRowsetClass(string $classname) : \Zend_Db_Table_Abstract
Inherited

Parameters

$classname

string

Returns

\Zend_Db_Table_AbstractProvides a fluent interface

Updates existing rows.

update(array $data, array|string $where) : integer
Inherited

Parameters

$data

array

Column-value pairs.

$where

arraystring

An SQL WHERE clause, or an array of SQL WHERE clauses.

Returns

integerThe number of rows updated.

Support method for fetching rows.

_fetch(\Zend_Db_Table_Select $select) : array
Inherited

Parameters

$select

\Zend_Db_Table_Select

query options.

Returns

arrayAn array containing the row results in FETCH_ASSOC mode.

Retrieve table columns

_getCols() : array
Inherited

Returns

array

Returns a normalized version of the reference map

_getReferenceMapNormalized() : array
Inherited

Returns

array

Generate ORDER clause from user-supplied string or array

_order(\Zend_Db_Table_Select $select, string|array $order) : \Zend_Db_Table_Select
Inherited

Parameters

$select

$order

stringarray

OPTIONAL An SQL ORDER clause.

Returns

\Zend_Db_Table_Select

_setAdapter()

_setAdapter(mixed $db) : \Zend_Db_Table_Abstract
Inherited

Parameters

$db

mixed

Either an Adapter object, or a string naming a Registry key

Returns

\Zend_Db_Table_AbstractProvides a fluent interface

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

_setMetadataCache(mixed $metadataCache) : \Zend_Db_Table_Abstract
Inherited

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

$metadataCache

mixed

Either a Cache object, or a string naming a Registry key

Returns

\Zend_Db_Table_AbstractProvides a fluent interface

Sets the sequence member, which defines the behavior for generating primary key values in new rows.

_setSequence(mixed $sequence) : \Zend_Db_Table_Adapter_Abstract
Inherited
  • 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

$sequence

mixed

Returns

\Zend_Db_Table_Adapter_AbstractProvides a fluent interface

Turnkey for initialization of a table object.

_setup() : void
Inherited

Calls other protected methods for individual tasks, to make it easier for a subclass to override part of the setup logic.

_setupAdapter()

_setupAdapter(mixed $db) : \Zend_Db_Adapter_Abstract
InheritedStatic

Parameters

$db

mixed

Either an Adapter object, or a string naming a Registry key

Exceptions

\Zend_Db_Table_Exception

Returns

\Zend_Db_Adapter_Abstract

Initialize database adapter.

_setupDatabaseAdapter() : void
Inherited

Exceptions

\Zend_Db_Table_Exception

_setupMetadataCache()

_setupMetadataCache(mixed $metadataCache) : \Zend_Cache_Core
InheritedStatic

Parameters

$metadataCache

mixed

Either a Cache object, or a string naming a Registry key

Exceptions

\Zend_Db_Table_Exception

Returns

\Zend_Cache_Core

Initialize primary key from metadata.

_setupPrimaryKey() : void
Inherited

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

Exceptions

\Zend_Db_Table_Exception

Initialize table and schema names.

_setupTableName() : void
Inherited

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.

Generate WHERE clause from user-supplied string or array

_where(\Zend_Db_Table_Select $select, string|array $where) : \Zend_Db_Table_Select
Inherited

Parameters

$select

$where

stringarray

OPTIONAL An SQL WHERE clause.

Returns

\Zend_Db_Table_Select

 Properties

 

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

$_cols : array

Default

 

Zend_Db_Adapter_Abstract object.

$_db : \Zend_Db_Adapter_Abstract

Default

 

Default Zend_Db_Adapter_Abstract object.

$_defaultDb : \Zend_Db_Adapter_Abstract

Default

Static
 

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

$_defaultMetadataCache : \Zend_Cache_Core

Default

null
Static
 

$_defaultSource

$_defaultSource 

Default

self::DEFAULT_NONE
 

$_defaultValues

$_defaultValues 

Default

array()
 

Optional Zend_Db_Table_Definition object

$_definition : \unknown_type

Default

null
 

Optional definition config name used in concrete implementation

$_definitionConfigName : string

Default

null
 

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.

$_dependentTables : array

Default

array()

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

 

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.

$_identity : integer

Default

1

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.

   

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

$_metadataCache : \Zend_Cache_Core

Default

null
 

Flag: whether or not to cache metadata in the class

$_metadataCacheInClass : boolean

Default

true
 

The table name.

$_name : string

Default

'queue'
inherited_from \Zend_Db_Table_Abstract::_name
 

The table name.

$_name : string

Default

null
 

The primary key column or columns.

$_primary : string

Default

'queue_id'

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

inherited_from \Zend_Db_Table_Abstract::_primary
 

The primary key column or columns.

$_primary : mixed

Default

null

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

 

Associative array map of declarative referential integrity rules.

$_referenceMap : array

Default

array()

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.
 

Classname for row

$_rowClass : string

Default

'Zend_Db_Table_Row'
 

Classname for rowset

$_rowsetClass : string

Default

'Zend_Db_Table_Rowset'
 

The schema name (default null means current schema)

$_schema : array

Default

null
 

Define the logic for new values in the primary key.

$_sequence : mixed

Default

true

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

inherited_from \Zend_Db_Table_Abstract::_sequence
 

Define the logic for new values in the primary key.

$_sequence : mixed

Default

true

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

 Constants

 

ADAPTER

ADAPTER = 'db' 
 

CASCADE

CASCADE = 'cascade' 
 

CASCADE_RECURSE

CASCADE_RECURSE = 'cascadeRecurse' 
 

COLS

COLS = 'cols' 
 

COLUMNS

COLUMNS = 'columns' 
 

DEFAULT_CLASS

DEFAULT_CLASS = 'defaultClass' 
 

DEFAULT_DB

DEFAULT_DB = 'defaultDb' 
 

DEFAULT_NONE

DEFAULT_NONE = 'defaultNone' 
 

DEFINITION

DEFINITION = 'definition' 
 

DEFINITION_CONFIG_NAME

DEFINITION_CONFIG_NAME = 'definitionConfigName' 
 

DEPENDENT_TABLES

DEPENDENT_TABLES = 'dependentTables' 
       

NAME

NAME = 'name' 
 

ON_DELETE

ON_DELETE = 'onDelete' 
 

ON_UPDATE

ON_UPDATE = 'onUpdate' 
 

PRIMARY

PRIMARY = 'primary' 
 

REFERENCE_MAP

REFERENCE_MAP = 'referenceMap' 
 

REF_COLUMNS

REF_COLUMNS = 'refColumns' 
 

REF_TABLE_CLASS

REF_TABLE_CLASS = 'refTableClass' 
 

RESTRICT

RESTRICT = 'restrict' 
 

ROWSET_CLASS

ROWSET_CLASS = 'rowsetClass' 
 

ROW_CLASS

ROW_CLASS = 'rowClass' 
 

SCHEMA

SCHEMA = 'schema' 
 

SELECT_WITHOUT_FROM_PART

SELECT_WITHOUT_FROM_PART = false 
 

SELECT_WITH_FROM_PART

SELECT_WITH_FROM_PART = true 
 

SEQUENCE

SEQUENCE = 'sequence' 
 

SET_NULL

SET_NULL = 'setNull'