Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Public Member Functions | Static Public Member Functions | Data Fields | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes
Zend_Db_Table_Abstract Class Reference
Inheritance diagram for Zend_Db_Table_Abstract:
Zend_Db_Table Zend_Session_SaveHandler_DbTable

Public Member Functions

 __construct ($config=array())
 
 setOptions (Array $options)
 
 setDefinition (Zend_Db_Table_Definition $definition)
 
 getDefinition ()
 
 setDefinitionConfigName ($definitionConfigName)
 
 getDefinitionConfigName ()
 
 setRowClass ($classname)
 
 getRowClass ()
 
 setRowsetClass ($classname)
 
 getRowsetClass ()
 
 addReference ($ruleKey, $columns, $refTableClass, $refColumns, $onDelete=null, $onUpdate=null)
 
 setReferences (array $referenceMap)
 
 getReference ($tableClassname, $ruleKey=null)
 
 setDependentTables (array $dependentTables)
 
 getDependentTables ()
 
 setDefaultSource ($defaultSource=self::DEFAULT_NONE)
 
 getDefaultSource ()
 
 setDefaultValues (Array $defaultValues)
 
 getDefaultValues ()
 
 getAdapter ()
 
 getMetadataCache ()
 
 setMetadataCacheInClass ($flag)
 
 metadataCacheInClass ()
 
 init ()
 
 info ($key=null)
 
 select ($withFromPart=self::SELECT_WITHOUT_FROM_PART)
 
 insert (array $data)
 
 isIdentity ($column)
 
 update (array $data, $where)
 
 _cascadeUpdate ($parentTableClassname, array $oldPrimaryKey, array $newPrimaryKey)
 
 delete ($where)
 
 _cascadeDelete ($parentTableClassname, array $primaryKey)
 
 find ()
 
 fetchAll ($where=null, $order=null, $count=null, $offset=null)
 
 fetchRow ($where=null, $order=null, $offset=null)
 
 fetchNew ()
 
 createRow (array $data=array(), $defaultSource=null)
 

Static Public Member Functions

static setDefaultAdapter ($db=null)
 
static getDefaultAdapter ()
 
static setDefaultMetadataCache ($metadataCache=null)
 
static getDefaultMetadataCache ()
 
static getTableFromString ($tableName, Zend_Db_Table_Abstract $referenceTable=null)
 

Data Fields

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)
 
 _setSequence ($sequence)
 
 _setup ()
 
 _setupDatabaseAdapter ()
 
 _setupTableName ()
 
 _setupMetadata ()
 
 _getCols ()
 
 _setupPrimaryKey ()
 
 _getReferenceMapNormalized ()
 
 _where (Zend_Db_Table_Select $select, $where)
 
 _order (Zend_Db_Table_Select $select, $order)
 
 _fetch (Zend_Db_Table_Select $select)
 

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
 

Detailed Description

Definition at line 47 of file Abstract.php.

Constructor & Destructor Documentation

◆ __construct()

__construct (   $config = array())

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().
Parameters
mixed$configArray of user-specified config options, or just the Db Adapter.
Returns
void

Allow a scalar argument to be the Adapter object or Registry key.

Definition at line 256 of file Abstract.php.

257  {
261  if (!is_array($config)) {
262  $config = array(self::ADAPTER => $config);
263  }
264 
265  if ($config) {
266  $this->setOptions($config);
267  }
268 
269  $this->_setup();
270  $this->init();
271  }
setOptions(Array $options)
Definition: Abstract.php:279
$config
Definition: fraud_order.php:17

Member Function Documentation

◆ _cascadeDelete()

_cascadeDelete (   $parentTableClassname,
array  $primaryKey 
)

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

Parameters
string$parentTableClassname
array$primaryKey
Returns
int Number of affected rows

Execute cascading deletes against dependent tables

Definition at line 1213 of file Abstract.php.

1214  {
1215  // setup metadata
1216  $this->_setupMetadata();
1217 
1218  // get this class name
1219  $thisClass = get_class($this);
1220  if ($thisClass === 'Zend_Db_Table') {
1221  $thisClass = $this->_definitionConfigName;
1222  }
1223 
1224  $rowsAffected = 0;
1225 
1226  foreach ($this->_getReferenceMapNormalized() as $map) {
1227  if ($map[self::REF_TABLE_CLASS] == $parentTableClassname && isset($map[self::ON_DELETE])) {
1228 
1229  $where = array();
1230 
1231  // CASCADE or CASCADE_RECURSE
1232  if (in_array($map[self::ON_DELETE], array(self::CASCADE, self::CASCADE_RECURSE))) {
1233  for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
1234  $col = $this->_db->foldCase($map[self::COLUMNS][$i]);
1235  $refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
1236  $type = $this->_metadata[$col]['DATA_TYPE'];
1237  $where[] = $this->_db->quoteInto(
1238  $this->_db->quoteIdentifier($col, true) . ' = ?',
1239  $primaryKey[$refCol], $type);
1240  }
1241  }
1242 
1243  // CASCADE_RECURSE
1244  if ($map[self::ON_DELETE] == self::CASCADE_RECURSE) {
1245 
1249  $depTables = $this->getDependentTables();
1250  if (!empty($depTables)) {
1251  foreach ($depTables as $tableClass) {
1252  $t = self::getTableFromString($tableClass, $this);
1253  foreach ($this->fetchAll($where) as $depRow) {
1254  $rowsAffected += $t->_cascadeDelete($thisClass, $depRow->getPrimaryKey());
1255  }
1256  }
1257  }
1258  }
1259 
1260  // CASCADE or CASCADE_RECURSE
1261  if (in_array($map[self::ON_DELETE], array(self::CASCADE, self::CASCADE_RECURSE))) {
1262  $rowsAffected += $this->delete($where);
1263  }
1264 
1265  }
1266  }
1267  return $rowsAffected;
1268  }
fetchAll($where=null, $order=null, $count=null, $offset=null)
Definition: Abstract.php:1387
$type
Definition: item.phtml:13
$i
Definition: gallery.phtml:31
static getTableFromString($tableName, Zend_Db_Table_Abstract $referenceTable=null)
Definition: Abstract.php:1606

◆ _cascadeUpdate()

_cascadeUpdate (   $parentTableClassname,
array  $oldPrimaryKey,
array  $newPrimaryKey 
)

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

Parameters
string$parentTableClassname
array$oldPrimaryKey
array$newPrimaryKey
Returns
int

Definition at line 1144 of file Abstract.php.

1145  {
1146  $this->_setupMetadata();
1147  $rowsAffected = 0;
1148  foreach ($this->_getReferenceMapNormalized() as $map) {
1149  if ($map[self::REF_TABLE_CLASS] == $parentTableClassname && isset($map[self::ON_UPDATE])) {
1150  switch ($map[self::ON_UPDATE]) {
1151  case self::CASCADE:
1152  $newRefs = array();
1153  $where = array();
1154  for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
1155  $col = $this->_db->foldCase($map[self::COLUMNS][$i]);
1156  $refCol = $this->_db->foldCase($map[self::REF_COLUMNS][$i]);
1157  if (array_key_exists($refCol, $newPrimaryKey)) {
1158  $newRefs[$col] = $newPrimaryKey[$refCol];
1159  }
1160  $type = $this->_metadata[$col]['DATA_TYPE'];
1161  $where[] = $this->_db->quoteInto(
1162  $this->_db->quoteIdentifier($col, true) . ' = ?',
1163  $oldPrimaryKey[$refCol], $type);
1164  }
1165  $rowsAffected += $this->update($newRefs, $where);
1166  break;
1167  default:
1168  // no action
1169  break;
1170  }
1171  }
1172  }
1173  return $rowsAffected;
1174  }
$type
Definition: item.phtml:13
update(array $data, $where)
Definition: Abstract.php:1130
$i
Definition: gallery.phtml:31

◆ _fetch()

_fetch ( Zend_Db_Table_Select  $select)
protected

Support method for fetching rows.

Parameters
Zend_Db_Table_Select$selectquery options.
Returns
array An array containing the row results in FETCH_ASSOC mode.

Definition at line 1591 of file Abstract.php.

1592  {
1593  $stmt = $this->_db->query($select);
1594  $data = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
1595  return $data;
1596  }
const FETCH_ASSOC
Definition: Db.php:142

◆ _getCols()

_getCols ( )
protected

Retrieve table columns

Returns
array

Definition at line 855 of file Abstract.php.

856  {
857  if (null === $this->_cols) {
858  $this->_setupMetadata();
859  $this->_cols = array_keys($this->_metadata);
860  }
861  return $this->_cols;
862  }

◆ _getReferenceMapNormalized()

_getReferenceMapNormalized ( )
protected

Returns a normalized version of the reference map

Returns
array

Definition at line 928 of file Abstract.php.

929  {
930  $referenceMapNormalized = array();
931 
932  foreach ($this->_referenceMap as $rule => $map) {
933 
934  $referenceMapNormalized[$rule] = array();
935 
936  foreach ($map as $key => $value) {
937  switch ($key) {
938 
939  // normalize COLUMNS and REF_COLUMNS to arrays
940  case self::COLUMNS:
941  case self::REF_COLUMNS:
942  if (!is_array($value)) {
943  $referenceMapNormalized[$rule][$key] = array($value);
944  } else {
945  $referenceMapNormalized[$rule][$key] = $value;
946  }
947  break;
948 
949  // other values are copied as-is
950  default:
951  $referenceMapNormalized[$rule][$key] = $value;
952  break;
953  }
954  }
955  }
956 
957  return $referenceMapNormalized;
958  }
$value
Definition: gender.phtml:16

◆ _order()

_order ( Zend_Db_Table_Select  $select,
  $order 
)
protected

Generate ORDER clause from user-supplied string or array

Parameters
string | array$orderOPTIONAL An SQL ORDER clause.
Returns
Zend_Db_Table_Select

Definition at line 1572 of file Abstract.php.

1573  {
1574  if (!is_array($order)) {
1575  $order = array($order);
1576  }
1577 
1578  foreach ($order as $val) {
1579  $select->order($val);
1580  }
1581 
1582  return $select;
1583  }
$order
Definition: order.php:55

◆ _setAdapter()

_setAdapter (   $db)
protected
Parameters
mixed$dbEither an Adapter object, or a string naming a Registry key
Returns
Zend_Db_Table_Abstract Provides a fluent interface

Definition at line 580 of file Abstract.php.

581  {
582  $this->_db = self::_setupAdapter($db);
583  return $this;
584  }
static _setupAdapter($db)
Definition: Abstract.php:601

◆ _setMetadataCache()

_setMetadataCache (   $metadataCache)
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.

Parameters
mixed$metadataCacheEither a Cache object, or a string naming a Registry key
Returns
Zend_Db_Table_Abstract Provides a fluent interface

Definition at line 651 of file Abstract.php.

652  {
653  $this->_metadataCache = self::_setupMetadataCache($metadataCache);
654  return $this;
655  }
static _setupMetadataCache($metadataCache)
Definition: Abstract.php:696

◆ _setSequence()

_setSequence (   $sequence)
protected

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.
Parameters
mixed$sequence
Returns
Zend_Db_Table_Adapter_Abstract Provides a fluent interface

Definition at line 724 of file Abstract.php.

725  {
726  $this->_sequence = $sequence;
727 
728  return $this;
729  }

◆ _setup()

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

Returns
void

Definition at line 738 of file Abstract.php.

739  {
740  $this->_setupDatabaseAdapter();
741  $this->_setupTableName();
742  }

◆ _setupAdapter()

static _setupAdapter (   $db)
staticprotected
Parameters
mixed$dbEither an Adapter object, or a string naming a Registry key
Returns
Zend_Db_Adapter_Abstract
Exceptions
Zend_Db_Table_Exception

Definition at line 601 of file Abstract.php.

602  {
603  if ($db === null) {
604  return null;
605  }
606  if (is_string($db)) {
607  #require_once 'Zend/Registry.php';
608  $db = Zend_Registry::get($db);
609  }
610  if (!$db instanceof Zend_Db_Adapter_Abstract) {
611  #require_once 'Zend/Db/Table/Exception.php';
612  throw new Zend_Db_Table_Exception('Argument must be of type Zend_Db_Adapter_Abstract, or a Registry key where a Zend_Db_Adapter_Abstract object is stored');
613  }
614  return $db;
615  }
static get($index)
Definition: Registry.php:141

◆ _setupDatabaseAdapter()

_setupDatabaseAdapter ( )
protected

Initialize database adapter.

Returns
void
Exceptions
Zend_Db_Table_Exception

Definition at line 750 of file Abstract.php.

751  {
752  if (! $this->_db) {
753  $this->_db = self::getDefaultAdapter();
754  if (!$this->_db instanceof Zend_Db_Adapter_Abstract) {
755  #require_once 'Zend/Db/Table/Exception.php';
756  throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this));
757  }
758  }
759  }
static getDefaultAdapter()
Definition: Abstract.php:571

◆ _setupMetadata()

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

Returns
boolean
Exceptions
Zend_Db_Table_Exception

Definition at line 790 of file Abstract.php.

791  {
792  if ($this->metadataCacheInClass() && (count($this->_metadata) > 0)) {
793  return true;
794  }
795 
796  // Assume that metadata will be loaded from cache
797  $isMetadataFromCache = true;
798 
799  // If $this has no metadata cache but the class has a default metadata cache
800  if (null === $this->_metadataCache && null !== self::$_defaultMetadataCache) {
801  // Make $this use the default metadata cache of the class
802  $this->_setMetadataCache(self::$_defaultMetadataCache);
803  }
804 
805  // If $this has a metadata cache
806  if (null !== $this->_metadataCache) {
807  // Define the cache identifier where the metadata are saved
808 
809  //get db configuration
810  $dbConfig = $this->_db->getConfig();
811 
812  $port = isset($dbConfig['options']['port'])
813  ? ':'.$dbConfig['options']['port']
814  : (isset($dbConfig['port'])
815  ? ':'.$dbConfig['port']
816  : null);
817 
818  $host = isset($dbConfig['options']['host'])
819  ? ':'.$dbConfig['options']['host']
820  : (isset($dbConfig['host'])
821  ? ':'.$dbConfig['host']
822  : null);
823 
824  // Define the cache identifier where the metadata are saved
825  $cacheId = md5( // port:host/dbname:schema.table (based on availabilty)
826  $port . $host . '/'. $dbConfig['dbname'] . ':'
827  . $this->_schema. '.' . $this->_name
828  );
829  }
830 
831  // If $this has no metadata cache or metadata cache misses
832  if (null === $this->_metadataCache || !($metadata = $this->_metadataCache->load($cacheId))) {
833  // Metadata are not loaded from cache
834  $isMetadataFromCache = false;
835  // Fetch metadata from the adapter's describeTable() method
836  $metadata = $this->_db->describeTable($this->_name, $this->_schema);
837  // If $this has a metadata cache, then cache the metadata
838  if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) {
839  trigger_error('Failed saving metadata to metadataCache', E_USER_NOTICE);
840  }
841  }
842 
843  // Assign the metadata to $this
844  $this->_metadata = $metadata;
845 
846  // Return whether the metadata were loaded from cache
847  return $isMetadataFromCache;
848  }
_setMetadataCache($metadataCache)
Definition: Abstract.php:651

◆ _setupMetadataCache()

static _setupMetadataCache (   $metadataCache)
staticprotected
Parameters
mixed$metadataCacheEither a Cache object, or a string naming a Registry key
Returns
Zend_Cache_Core
Exceptions
Zend_Db_Table_Exception

Definition at line 696 of file Abstract.php.

697  {
698  if ($metadataCache === null) {
699  return null;
700  }
701  if (is_string($metadataCache)) {
702  #require_once 'Zend/Registry.php';
703  $metadataCache = Zend_Registry::get($metadataCache);
704  }
705  if (!$metadataCache instanceof Zend_Cache_Core) {
706  #require_once 'Zend/Db/Table/Exception.php';
707  throw new Zend_Db_Table_Exception('Argument must be of type Zend_Cache_Core, or a Registry key where a Zend_Cache_Core object is stored');
708  }
709  return $metadataCache;
710  }
static get($index)
Definition: Registry.php:141

◆ _setupPrimaryKey()

_setupPrimaryKey ( )
protected

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

Returns
void
Exceptions
Zend_Db_Table_Exception

Special case for PostgreSQL: a SERIAL key implicitly uses a sequence object whose name is "<table>_<column>_seq".

Definition at line 872 of file Abstract.php.

873  {
874  if (!$this->_primary) {
875  $this->_setupMetadata();
876  $this->_primary = array();
877  foreach ($this->_metadata as $col) {
878  if ($col['PRIMARY']) {
879  $this->_primary[ $col['PRIMARY_POSITION'] ] = $col['COLUMN_NAME'];
880  if ($col['IDENTITY']) {
881  $this->_identity = $col['PRIMARY_POSITION'];
882  }
883  }
884  }
885  // if no primary key was specified and none was found in the metadata
886  // then throw an exception.
887  if (empty($this->_primary)) {
888  #require_once 'Zend/Db/Table/Exception.php';
889  throw new Zend_Db_Table_Exception("A table must have a primary key, but none was found for table '{$this->_name}'");
890  }
891  } else if (!is_array($this->_primary)) {
892  $this->_primary = array(1 => $this->_primary);
893  } else if (isset($this->_primary[0])) {
894  array_unshift($this->_primary, null);
895  unset($this->_primary[0]);
896  }
897 
898  $cols = $this->_getCols();
899  if (! array_intersect((array) $this->_primary, $cols) == (array) $this->_primary) {
900  #require_once 'Zend/Db/Table/Exception.php';
901  throw new Zend_Db_Table_Exception("Primary key column(s) ("
902  . implode(',', (array) $this->_primary)
903  . ") are not columns in this table ("
904  . implode(',', $cols)
905  . ")");
906  }
907 
908  $primary = (array) $this->_primary;
909  $pkIdentity = $primary[(int) $this->_identity];
910 
915  if ($this->_sequence === true && $this->_db instanceof Zend_Db_Adapter_Pdo_Pgsql) {
916  $this->_sequence = $this->_db->quoteIdentifier("{$this->_name}_{$pkIdentity}_seq");
917  if ($this->_schema) {
918  $this->_sequence = $this->_db->quoteIdentifier($this->_schema) . '.' . $this->_sequence;
919  }
920  }
921  }

◆ _setupTableName()

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

Returns
void

Definition at line 772 of file Abstract.php.

773  {
774  if (! $this->_name) {
775  $this->_name = get_class($this);
776  } else if (strpos($this->_name, '.')) {
777  list($this->_schema, $this->_name) = explode('.', $this->_name);
778  }
779  }

◆ _where()

_where ( Zend_Db_Table_Select  $select,
  $where 
)
protected

Generate WHERE clause from user-supplied string or array

Parameters
string | array$whereOPTIONAL An SQL WHERE clause.
Returns
Zend_Db_Table_Select

Definition at line 1547 of file Abstract.php.

1548  {
1549  $where = (array) $where;
1550 
1551  foreach ($where as $key => $val) {
1552  // is $key an int?
1553  if (is_int($key)) {
1554  // $val is the full condition
1555  $select->where($val);
1556  } else {
1557  // $key is the condition with placeholder,
1558  // and $val is quoted into the condition
1559  $select->where($key, $val);
1560  }
1561  }
1562 
1563  return $select;
1564  }

◆ addReference()

addReference (   $ruleKey,
  $columns,
  $refTableClass,
  $refColumns,
  $onDelete = null,
  $onUpdate = null 
)

Add a reference to the reference map

Parameters
string$ruleKey
string | array$columns
string$refTableClass
string | array$refColumns
string$onDelete
string$onUpdate
Returns
Zend_Db_Table_Abstract

Definition at line 424 of file Abstract.php.

426  {
427  $reference = array(self::COLUMNS => (array) $columns,
428  self::REF_TABLE_CLASS => $refTableClass,
429  self::REF_COLUMNS => (array) $refColumns);
430 
431  if (!empty($onDelete)) {
432  $reference[self::ON_DELETE] = $onDelete;
433  }
434 
435  if (!empty($onUpdate)) {
436  $reference[self::ON_UPDATE] = $onUpdate;
437  }
438 
439  $this->_referenceMap[$ruleKey] = $reference;
440 
441  return $this;
442  }
$columns
Definition: default.phtml:15

◆ createRow()

createRow ( array  $data = array(),
  $defaultSource = null 
)

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

Parameters
array$dataOPTIONAL data to populate in the new row.
string$defaultSourceOPTIONAL flag to force default values into new row
Returns
Zend_Db_Table_Row_Abstract

Definition at line 1494 of file Abstract.php.

1495  {
1496  $cols = $this->_getCols();
1497  $defaults = array_combine($cols, array_fill(0, count($cols), null));
1498 
1499  // nothing provided at call-time, take the class value
1500  if ($defaultSource == null) {
1501  $defaultSource = $this->_defaultSource;
1502  }
1503 
1504  if (!in_array($defaultSource, array(self::DEFAULT_CLASS, self::DEFAULT_DB, self::DEFAULT_NONE))) {
1505  $defaultSource = self::DEFAULT_NONE;
1506  }
1507 
1508  if ($defaultSource == self::DEFAULT_DB) {
1509  foreach ($this->_metadata as $metadataName => $metadata) {
1510  if (($metadata['DEFAULT'] != null) &&
1511  ($metadata['NULLABLE'] !== true || ($metadata['NULLABLE'] === true && isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === true)) &&
1512  (!(isset($this->_defaultValues[$metadataName]) && $this->_defaultValues[$metadataName] === false))) {
1513  $defaults[$metadataName] = $metadata['DEFAULT'];
1514  }
1515  }
1516  } elseif ($defaultSource == self::DEFAULT_CLASS && $this->_defaultValues) {
1517  foreach ($this->_defaultValues as $defaultName => $defaultValue) {
1518  if (array_key_exists($defaultName, $defaults)) {
1519  $defaults[$defaultName] = $defaultValue;
1520  }
1521  }
1522  }
1523 
1524  $config = array(
1525  'table' => $this,
1526  'data' => $defaults,
1527  'readOnly' => false,
1528  'stored' => false
1529  );
1530 
1531  $rowClass = $this->getRowClass();
1532  if (!class_exists($rowClass)) {
1533  #require_once 'Zend/Loader.php';
1534  Zend_Loader::loadClass($rowClass);
1535  }
1536  $row = new $rowClass($config);
1537  $row->setFromArray($data);
1538  return $row;
1539  }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
static loadClass($class, $dirs=null)
Definition: Loader.php:52
$config
Definition: fraud_order.php:17

◆ delete()

delete (   $where)

Deletes existing rows.

Parameters
array | string$whereSQL WHERE clause(s).
Returns
int The number of rows deleted.

Execute cascading deletes against dependent tables

Definition at line 1182 of file Abstract.php.

1183  {
1184  $depTables = $this->getDependentTables();
1185  if (!empty($depTables)) {
1186  $resultSet = $this->fetchAll($where);
1187  if (count($resultSet) > 0 ) {
1188  foreach ($resultSet as $row) {
1192  foreach ($depTables as $tableClass) {
1193  $t = self::getTableFromString($tableClass, $this);
1194  $t->_cascadeDelete(
1195  get_class($this), $row->getPrimaryKey()
1196  );
1197  }
1198  }
1199  }
1200  }
1201 
1202  $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
1203  return $this->_db->delete($tableSpec, $where);
1204  }
fetchAll($where=null, $order=null, $count=null, $offset=null)
Definition: Abstract.php:1387
static getTableFromString($tableName, Zend_Db_Table_Abstract $referenceTable=null)
Definition: Abstract.php:1606

◆ fetchAll()

fetchAll (   $where = null,
  $order = null,
  $count = null,
  $offset = null 
)

Fetches all rows.

Honors the Zend_Db_Adapter fetch mode.

Parameters
string | array | Zend_Db_Table_Select$whereOPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.
string | array$orderOPTIONAL An SQL ORDER clause.
int$countOPTIONAL An SQL LIMIT count.
int$offsetOPTIONAL An SQL LIMIT offset.
Returns
Zend_Db_Table_Rowset_Abstract The row results per the Zend_Db_Adapter fetch mode.

Definition at line 1387 of file Abstract.php.

1388  {
1389  if (!($where instanceof Zend_Db_Table_Select)) {
1390  $select = $this->select();
1391 
1392  if ($where !== null) {
1393  $this->_where($select, $where);
1394  }
1395 
1396  if ($order !== null) {
1397  $this->_order($select, $order);
1398  }
1399 
1400  if ($count !== null || $offset !== null) {
1401  $select->limit($count, $offset);
1402  }
1403 
1404  } else {
1405  $select = $where;
1406  }
1407 
1408  $rows = $this->_fetch($select);
1409 
1410  $data = array(
1411  'table' => $this,
1412  'data' => $rows,
1413  'readOnly' => $select->isReadOnly(),
1414  'rowClass' => $this->getRowClass(),
1415  'stored' => true
1416  );
1417 
1418  $rowsetClass = $this->getRowsetClass();
1419  if (!class_exists($rowsetClass)) {
1420  #require_once 'Zend/Loader.php';
1421  Zend_Loader::loadClass($rowsetClass);
1422  }
1423  return new $rowsetClass($data);
1424  }
_order(Zend_Db_Table_Select $select, $order)
Definition: Abstract.php:1572
static loadClass($class, $dirs=null)
Definition: Loader.php:52
$count
Definition: recent.phtml:13
$order
Definition: order.php:55
_fetch(Zend_Db_Table_Select $select)
Definition: Abstract.php:1591
_where(Zend_Db_Table_Select $select, $where)
Definition: Abstract.php:1547
select($withFromPart=self::SELECT_WITHOUT_FROM_PART)
Definition: Abstract.php:1016

◆ fetchNew()

fetchNew ( )

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

Returns
Zend_Db_Table_Row_Abstract
Deprecated:
since 0.9.3 - use createRow() instead.

Definition at line 1482 of file Abstract.php.

1483  {
1484  return $this->createRow();
1485  }
createRow(array $data=array(), $defaultSource=null)
Definition: Abstract.php:1494

◆ fetchRow()

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.

Parameters
string | array | Zend_Db_Table_Select$whereOPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.
string | array$orderOPTIONAL An SQL ORDER clause.
int$offsetOPTIONAL An SQL OFFSET value.
Returns
Zend_Db_Table_Row_Abstract|null The row results per the Zend_Db_Adapter fetch mode, or null if no row found.

Definition at line 1436 of file Abstract.php.

1437  {
1438  if (!($where instanceof Zend_Db_Table_Select)) {
1439  $select = $this->select();
1440 
1441  if ($where !== null) {
1442  $this->_where($select, $where);
1443  }
1444 
1445  if ($order !== null) {
1446  $this->_order($select, $order);
1447  }
1448 
1449  $select->limit(1, ((is_numeric($offset)) ? (int) $offset : null));
1450 
1451  } else {
1452  $select = $where->limit(1, $where->getPart(Zend_Db_Select::LIMIT_OFFSET));
1453  }
1454 
1455  $rows = $this->_fetch($select);
1456 
1457  if (count($rows) == 0) {
1458  return null;
1459  }
1460 
1461  $data = array(
1462  'table' => $this,
1463  'data' => $rows[0],
1464  'readOnly' => $select->isReadOnly(),
1465  'stored' => true
1466  );
1467 
1468  $rowClass = $this->getRowClass();
1469  if (!class_exists($rowClass)) {
1470  #require_once 'Zend/Loader.php';
1471  Zend_Loader::loadClass($rowClass);
1472  }
1473  return new $rowClass($data);
1474  }
_order(Zend_Db_Table_Select $select, $order)
Definition: Abstract.php:1572
static loadClass($class, $dirs=null)
Definition: Loader.php:52
$order
Definition: order.php:55
const LIMIT_OFFSET
Definition: Select.php:56
_fetch(Zend_Db_Table_Select $select)
Definition: Abstract.php:1591
_where(Zend_Db_Table_Select $select, $where)
Definition: Abstract.php:1547
select($withFromPart=self::SELECT_WITHOUT_FROM_PART)
Definition: Abstract.php:1016

◆ find()

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.

Parameters
mixed$keyThe value(s) of the primary keys.
Returns
Zend_Db_Table_Rowset_Abstract Row(s) matching the criteria.
Exceptions
Zend_Db_Table_Exception

PHP 7.2 PATCH -->

PHP 7.2 PATCH <–

Definition at line 1288 of file Abstract.php.

1289  {
1290  $this->_setupPrimaryKey();
1291  $args = func_get_args();
1292  $keyNames = array_values((array) $this->_primary);
1293 
1294  if (count($args) < count($keyNames)) {
1295  #require_once 'Zend/Db/Table/Exception.php';
1296  throw new Zend_Db_Table_Exception("Too few columns for the primary key");
1297  }
1298 
1299  if (count($args) > count($keyNames)) {
1300  #require_once 'Zend/Db/Table/Exception.php';
1301  throw new Zend_Db_Table_Exception("Too many columns for the primary key");
1302  }
1303 
1304  $whereList = array();
1305  $numberTerms = 0;
1306  foreach ($args as $keyPosition => $keyValues) {
1310  if (is_array($keyValues) || $keyValues instanceof \Countable) {
1311  $keyValuesCount = count($keyValues);
1312  } else {
1313  if (null == $keyValues) {
1314  $keyValuesCount = 0;
1315  } else {
1316  $keyValuesCount = 1;
1317  }
1318  }
1319  #$keyValuesCount = count($keyValues);
1320 
1324  // Coerce the values to an array.
1325  // Don't simply typecast to array, because the values
1326  // might be Zend_Db_Expr objects.
1327  if (!is_array($keyValues)) {
1328  $keyValues = array($keyValues);
1329  }
1330  if ($numberTerms == 0) {
1331  $numberTerms = $keyValuesCount;
1332  } else if ($keyValuesCount != $numberTerms) {
1333  #require_once 'Zend/Db/Table/Exception.php';
1334  throw new Zend_Db_Table_Exception("Missing value(s) for the primary key");
1335  }
1336  $keyValues = array_values($keyValues);
1337  for ($i = 0; $i < $keyValuesCount; ++$i) {
1338  if (!isset($whereList[$i])) {
1339  $whereList[$i] = array();
1340  }
1341  $whereList[$i][$keyPosition] = $keyValues[$i];
1342  }
1343  }
1344 
1345  $whereClause = null;
1346  if (count($whereList)) {
1347  $whereOrTerms = array();
1348  $tableName = $this->_db->quoteTableAs($this->_name, null, true);
1349  foreach ($whereList as $keyValueSets) {
1350  $whereAndTerms = array();
1351  foreach ($keyValueSets as $keyPosition => $keyValue) {
1352  $type = $this->_metadata[$keyNames[$keyPosition]]['DATA_TYPE'];
1353  $columnName = $this->_db->quoteIdentifier($keyNames[$keyPosition], true);
1354  $whereAndTerms[] = $this->_db->quoteInto(
1355  $tableName . '.' . $columnName . ' = ?',
1356  $keyValue, $type);
1357  }
1358  $whereOrTerms[] = '(' . implode(' AND ', $whereAndTerms) . ')';
1359  }
1360  $whereClause = '(' . implode(' OR ', $whereOrTerms) . ')';
1361  }
1362 
1363  // issue ZF-5775 (empty where clause should return empty rowset)
1364  if ($whereClause == null) {
1365  $rowsetClass = $this->getRowsetClass();
1366  if (!class_exists($rowsetClass)) {
1367  #require_once 'Zend/Loader.php';
1368  Zend_Loader::loadClass($rowsetClass);
1369  }
1370  return new $rowsetClass(array('table' => $this, 'rowClass' => $this->getRowClass(), 'stored' => true));
1371  }
1372 
1373  return $this->fetchAll($whereClause);
1374  }
$tableName
Definition: trigger.php:13
static loadClass($class, $dirs=null)
Definition: Loader.php:52
fetchAll($where=null, $order=null, $count=null, $offset=null)
Definition: Abstract.php:1387
$type
Definition: item.phtml:13
$i
Definition: gallery.phtml:31

◆ getAdapter()

getAdapter ( )

Gets the Zend_Db_Adapter_Abstract for this particular Zend_Db_Table object.

Returns
Zend_Db_Adapter_Abstract

Definition at line 591 of file Abstract.php.

592  {
593  return $this->_db;
594  }

◆ getDefaultAdapter()

static getDefaultAdapter ( )
static

Gets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.

Returns
Zend_Db_Adapter_Abstract or null

Definition at line 571 of file Abstract.php.

572  {
573  return self::$_defaultDb;
574  }

◆ getDefaultMetadataCache()

static getDefaultMetadataCache ( )
static

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

Returns
Zend_Cache_Core or null

Definition at line 635 of file Abstract.php.

636  {
638  }
static $_defaultMetadataCache
Definition: Abstract.php:110

◆ getDefaultSource()

getDefaultSource ( )

returns the default source flag that determines where defaultSources come from

Returns
unknown

Definition at line 528 of file Abstract.php.

529  {
530  return $this->_defaultSource;
531  }

◆ getDefaultValues()

getDefaultValues ( )

Definition at line 549 of file Abstract.php.

550  {
551  return $this->_defaultValues;
552  }

◆ getDefinition()

getDefinition ( )

getDefinition()

Returns
Zend_Db_Table_Definition|null

Definition at line 348 of file Abstract.php.

349  {
350  return $this->_definition;
351  }

◆ getDefinitionConfigName()

getDefinitionConfigName ( )

getDefinitionConfigName()

Returns
string

Definition at line 370 of file Abstract.php.

371  {
373  }

◆ getDependentTables()

getDependentTables ( )
Returns
array

Definition at line 502 of file Abstract.php.

503  {
505  }

◆ getMetadataCache()

getMetadataCache ( )

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

Returns
Zend_Cache_Core or null

Definition at line 662 of file Abstract.php.

663  {
664  return $this->_metadataCache;
665  }

◆ getReference()

getReference (   $tableClassname,
  $ruleKey = null 
)
Parameters
string$tableClassname
string$ruleKeyOPTIONAL
Returns
array
Exceptions
Zend_Db_Table_Exception

Definition at line 461 of file Abstract.php.

462  {
463  $thisClass = get_class($this);
464  if ($thisClass === 'Zend_Db_Table') {
465  $thisClass = $this->_definitionConfigName;
466  }
467  $refMap = $this->_getReferenceMapNormalized();
468  if ($ruleKey !== null) {
469  if (!isset($refMap[$ruleKey])) {
470  #require_once "Zend/Db/Table/Exception.php";
471  throw new Zend_Db_Table_Exception("No reference rule \"$ruleKey\" from table $thisClass to table $tableClassname");
472  }
473  if ($refMap[$ruleKey][self::REF_TABLE_CLASS] != $tableClassname) {
474  #require_once "Zend/Db/Table/Exception.php";
475  throw new Zend_Db_Table_Exception("Reference rule \"$ruleKey\" does not reference table $tableClassname");
476  }
477  return $refMap[$ruleKey];
478  }
479  foreach ($refMap as $reference) {
480  if ($reference[self::REF_TABLE_CLASS] == $tableClassname) {
481  return $reference;
482  }
483  }
484  #require_once "Zend/Db/Table/Exception.php";
485  throw new Zend_Db_Table_Exception("No reference from table $thisClass to table $tableClassname");
486  }

◆ getRowClass()

getRowClass ( )
Returns
string

Definition at line 389 of file Abstract.php.

390  {
391  return $this->_rowClass;
392  }

◆ getRowsetClass()

getRowsetClass ( )
Returns
string

Definition at line 408 of file Abstract.php.

409  {
410  return $this->_rowsetClass;
411  }

◆ getTableFromString()

static getTableFromString (   $tableName,
Zend_Db_Table_Abstract  $referenceTable = null 
)
static

Get table gateway object from string

Parameters
string$tableName
Zend_Db_Table_Abstract$referenceTable
Exceptions
Zend_Db_Table_Row_Exception
Returns
Zend_Db_Table_Abstract

Definition at line 1606 of file Abstract.php.

1607  {
1608  if ($referenceTable instanceof Zend_Db_Table_Abstract) {
1609  $tableDefinition = $referenceTable->getDefinition();
1610 
1611  if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) {
1612  return new Zend_Db_Table($tableName, $tableDefinition);
1613  }
1614  }
1615 
1616  // assume the tableName is the class name
1617  if (!class_exists($tableName)) {
1618  try {
1619  #require_once 'Zend/Loader.php';
1621  } catch (Zend_Exception $e) {
1622  #require_once 'Zend/Db/Table/Row/Exception.php';
1623  throw new Zend_Db_Table_Row_Exception($e->getMessage(), $e->getCode(), $e);
1624  }
1625  }
1626 
1627  $options = array();
1628 
1629  if ($referenceTable instanceof Zend_Db_Table_Abstract) {
1630  $options['db'] = $referenceTable->getAdapter();
1631  }
1632 
1633  if (isset($tableDefinition) && $tableDefinition !== null) {
1634  $options[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition;
1635  }
1636 
1637  return new $tableName($options);
1638  }
$tableName
Definition: trigger.php:13
static loadClass($class, $dirs=null)
Definition: Loader.php:52

◆ info()

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.

Parameters
string$keyThe specific info part to return OPTIONAL
Returns
mixed
Exceptions
Zend_Db_Table_Exception

Definition at line 981 of file Abstract.php.

982  {
983  $this->_setupPrimaryKey();
984 
985  $info = array(
986  self::SCHEMA => $this->_schema,
987  self::NAME => $this->_name,
988  self::COLS => $this->_getCols(),
989  self::PRIMARY => (array) $this->_primary,
990  self::METADATA => $this->_metadata,
991  self::ROW_CLASS => $this->getRowClass(),
992  self::ROWSET_CLASS => $this->getRowsetClass(),
993  self::REFERENCE_MAP => $this->_referenceMap,
994  self::DEPENDENT_TABLES => $this->_dependentTables,
995  self::SEQUENCE => $this->_sequence
996  );
997 
998  if ($key === null) {
999  return $info;
1000  }
1001 
1002  if (!array_key_exists($key, $info)) {
1003  #require_once 'Zend/Db/Table/Exception.php';
1004  throw new Zend_Db_Table_Exception('There is no table information for the key "' . $key . '"');
1005  }
1006 
1007  return $info[$key];
1008  }
foreach( $_productCollection as $_product)() ?>" class $info
Definition: listing.phtml:52

◆ init()

init ( )

Initialize object

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

Returns
void

Definition at line 967 of file Abstract.php.

968  {
969  }

◆ insert()

insert ( array  $data)

Inserts a new row.

Parameters
array$dataColumn-value pairs.
Returns
mixed The primary key of the row inserted.

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

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.

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.

Definition at line 1032 of file Abstract.php.

1033  {
1034  $this->_setupPrimaryKey();
1035 
1041  $primary = (array) $this->_primary;
1042  $pkIdentity = $primary[(int)$this->_identity];
1043 
1044 
1053  if (array_key_exists($pkIdentity, $data)) {
1054  if ($data[$pkIdentity] === null // null
1055  || $data[$pkIdentity] === '' // empty string
1056  || is_bool($data[$pkIdentity]) // boolean
1057  || (is_array($data[$pkIdentity]) && empty($data[$pkIdentity]))) { // empty array
1058  unset($data[$pkIdentity]);
1059  }
1060  }
1061 
1068  if (is_string($this->_sequence) && !isset($data[$pkIdentity])) {
1069  $data[$pkIdentity] = $this->_db->nextSequenceId($this->_sequence);
1070  }
1071 
1075  $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
1076  $this->_db->insert($tableSpec, $data);
1077 
1083  if ($this->_sequence === true && !isset($data[$pkIdentity])) {
1084  $data[$pkIdentity] = $this->_db->lastInsertId();
1085  }
1086 
1091  $pkData = array_intersect_key($data, array_flip($primary));
1092  if (count($primary) == 1) {
1093  reset($pkData);
1094  return current($pkData);
1095  }
1096 
1097  return $pkData;
1098  }

◆ isIdentity()

isIdentity (   $column)

Check if the provided column is an identity of the table

Parameters
string$column
Exceptions
Zend_Db_Table_Exception
Returns
boolean
See also
Zend_Db_Table_Exception

Definition at line 1107 of file Abstract.php.

1108  {
1109  $this->_setupPrimaryKey();
1110 
1111  if (!isset($this->_metadata[$column])) {
1115  #require_once 'Zend/Db/Table/Exception.php';
1116 
1117  throw new Zend_Db_Table_Exception('Column "' . $column . '" not found in table.');
1118  }
1119 
1120  return (bool) $this->_metadata[$column]['IDENTITY'];
1121  }

◆ metadataCacheInClass()

metadataCacheInClass ( )

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

Returns
bool

Definition at line 686 of file Abstract.php.

687  {
689  }

◆ select()

select (   $withFromPart = self::SELECT_WITHOUT_FROM_PART)

Returns an instance of a Zend_Db_Table_Select object.

Parameters
bool$withFromPartWhether or not to include the from part of the select based on the table
Returns
Zend_Db_Table_Select

Definition at line 1016 of file Abstract.php.

1017  {
1018  #require_once 'Zend/Db/Table/Select.php';
1019  $select = new Zend_Db_Table_Select($this);
1020  if ($withFromPart == self::SELECT_WITH_FROM_PART) {
1021  $select->from($this->info(self::NAME), Zend_Db_Table_Select::SQL_WILDCARD, $this->info(self::SCHEMA));
1022  }
1023  return $select;
1024  }
const SQL_WILDCARD
Definition: Select.php:66

◆ setDefaultAdapter()

static setDefaultAdapter (   $db = null)
static

Sets the default Zend_Db_Adapter_Abstract for all Zend_Db_Table objects.

Parameters
mixed$dbEither an Adapter object, or a string naming a Registry key
Returns
void

Definition at line 561 of file Abstract.php.

562  {
563  self::$_defaultDb = self::_setupAdapter($db);
564  }
static _setupAdapter($db)
Definition: Abstract.php:601

◆ setDefaultMetadataCache()

static setDefaultMetadataCache (   $metadataCache = null)
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.

Parameters
mixed$metadataCacheEither a Cache object, or a string naming a Registry key
Returns
void

Definition at line 625 of file Abstract.php.

626  {
627  self::$_defaultMetadataCache = self::_setupMetadataCache($metadataCache);
628  }
static _setupMetadataCache($metadataCache)
Definition: Abstract.php:696

◆ setDefaultSource()

setDefaultSource (   $defaultSource = self::DEFAULT_NONE)

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

Parameters
string$defaultSource
Returns
Zend_Db_Table_Abstract

Definition at line 513 of file Abstract.php.

514  {
515  if (!in_array($defaultSource, array(self::DEFAULT_CLASS, self::DEFAULT_DB, self::DEFAULT_NONE))) {
516  $defaultSource = self::DEFAULT_NONE;
517  }
518 
519  $this->_defaultSource = $defaultSource;
520  return $this;
521  }

◆ setDefaultValues()

setDefaultValues ( Array  $defaultValues)

set the default values for the table class

Parameters
array$defaultValues
Returns
Zend_Db_Table_Abstract

Definition at line 539 of file Abstract.php.

540  {
541  foreach ($defaultValues as $defaultName => $defaultValue) {
542  if (array_key_exists($defaultName, $this->_metadata)) {
543  $this->_defaultValues[$defaultName] = $defaultValue;
544  }
545  }
546  return $this;
547  }

◆ setDefinition()

setDefinition ( Zend_Db_Table_Definition  $definition)

setDefinition()

Parameters
Zend_Db_Table_Definition$definition
Returns
Zend_Db_Table_Abstract

Definition at line 337 of file Abstract.php.

338  {
339  $this->_definition = $definition;
340  return $this;
341  }

◆ setDefinitionConfigName()

setDefinitionConfigName (   $definitionConfigName)

setDefinitionConfigName()

Parameters
string$definition
Returns
Zend_Db_Table_Abstract

Definition at line 359 of file Abstract.php.

360  {
361  $this->_definitionConfigName = $definitionConfigName;
362  return $this;
363  }

◆ setDependentTables()

setDependentTables ( array  $dependentTables)
Parameters
array$dependentTables
Returns
Zend_Db_Table_Abstract Provides a fluent interface

Definition at line 492 of file Abstract.php.

493  {
494  $this->_dependentTables = $dependentTables;
495 
496  return $this;
497  }

◆ setMetadataCacheInClass()

setMetadataCacheInClass (   $flag)

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

Parameters
bool$flag
Returns
Zend_Db_Table_Abstract

Definition at line 674 of file Abstract.php.

675  {
676  $this->_metadataCacheInClass = (bool) $flag;
677  return $this;
678  }

◆ setOptions()

setOptions ( Array  $options)

setOptions()

Parameters
array$options
Returns
Zend_Db_Table_Abstract

Definition at line 279 of file Abstract.php.

280  {
281  foreach ($options as $key => $value) {
282  switch ($key) {
283  case self::ADAPTER:
284  $this->_setAdapter($value);
285  break;
286  case self::DEFINITION:
287  $this->setDefinition($value);
288  break;
291  break;
292  case self::SCHEMA:
293  $this->_schema = (string) $value;
294  break;
295  case self::NAME:
296  $this->_name = (string) $value;
297  break;
298  case self::PRIMARY:
299  $this->_primary = (array) $value;
300  break;
301  case self::ROW_CLASS:
302  $this->setRowClass($value);
303  break;
304  case self::ROWSET_CLASS:
305  $this->setRowsetClass($value);
306  break;
307  case self::REFERENCE_MAP:
308  $this->setReferences($value);
309  break;
311  $this->setDependentTables($value);
312  break;
314  $this->_setMetadataCache($value);
315  break;
318  break;
319  case self::SEQUENCE:
320  $this->_setSequence($value);
321  break;
322  default:
323  // ignore unrecognized configuration directive
324  break;
325  }
326  }
327 
328  return $this;
329  }
setDefinitionConfigName($definitionConfigName)
Definition: Abstract.php:359
setMetadataCacheInClass($flag)
Definition: Abstract.php:674
setReferences(array $referenceMap)
Definition: Abstract.php:448
const METADATA_CACHE_IN_CLASS
Definition: Abstract.php:59
setDependentTables(array $dependentTables)
Definition: Abstract.php:492
$value
Definition: gender.phtml:16
const DEFINITION_CONFIG_NAME
Definition: Abstract.php:52
setRowsetClass($classname)
Definition: Abstract.php:398
_setSequence($sequence)
Definition: Abstract.php:724
setDefinition(Zend_Db_Table_Definition $definition)
Definition: Abstract.php:337
_setMetadataCache($metadataCache)
Definition: Abstract.php:651
setRowClass($classname)
Definition: Abstract.php:379

◆ setReferences()

setReferences ( array  $referenceMap)
Parameters
array$referenceMap
Returns
Zend_Db_Table_Abstract Provides a fluent interface

Definition at line 448 of file Abstract.php.

449  {
450  $this->_referenceMap = $referenceMap;
451 
452  return $this;
453  }

◆ setRowClass()

setRowClass (   $classname)
Parameters
string$classname
Returns
Zend_Db_Table_Abstract Provides a fluent interface

Definition at line 379 of file Abstract.php.

380  {
381  $this->_rowClass = (string) $classname;
382 
383  return $this;
384  }

◆ setRowsetClass()

setRowsetClass (   $classname)
Parameters
string$classname
Returns
Zend_Db_Table_Abstract Provides a fluent interface

Definition at line 398 of file Abstract.php.

399  {
400  $this->_rowsetClass = (string) $classname;
401 
402  return $this;
403  }

◆ update()

update ( array  $data,
  $where 
)

Updates existing rows.

Parameters
array$dataColumn-value pairs.
array | string$whereAn SQL WHERE clause, or an array of SQL WHERE clauses.
Returns
int The number of rows updated.

Definition at line 1130 of file Abstract.php.

1131  {
1132  $tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
1133  return $this->_db->update($tableSpec, $data, $where);
1134  }

Field Documentation

◆ $_cols

$_cols
protected

Definition at line 138 of file Abstract.php.

◆ $_db

$_db
protected

Definition at line 117 of file Abstract.php.

◆ $_defaultDb

$_defaultDb
staticprotected

Definition at line 89 of file Abstract.php.

◆ $_defaultMetadataCache

$_defaultMetadataCache = null
staticprotected

Definition at line 110 of file Abstract.php.

◆ $_defaultSource

$_defaultSource = self::DEFAULT_NONE
protected

Definition at line 235 of file Abstract.php.

◆ $_defaultValues

$_defaultValues = array()
protected

Definition at line 236 of file Abstract.php.

◆ $_definition

$_definition = null
protected

Definition at line 96 of file Abstract.php.

◆ $_definitionConfigName

$_definitionConfigName = null
protected

Definition at line 103 of file Abstract.php.

◆ $_dependentTables

$_dependentTables = array()
protected

Definition at line 232 of file Abstract.php.

◆ $_identity

$_identity = 1
protected

Definition at line 160 of file Abstract.php.

◆ $_metadata

$_metadata = array()
protected

Definition at line 175 of file Abstract.php.

◆ $_metadataCache

$_metadataCache = null
protected

Definition at line 182 of file Abstract.php.

◆ $_metadataCacheInClass

$_metadataCacheInClass = true
protected

Definition at line 188 of file Abstract.php.

◆ $_name

$_name = null
protected

Definition at line 131 of file Abstract.php.

◆ $_primary

$_primary = null
protected

Definition at line 148 of file Abstract.php.

◆ $_referenceMap

$_referenceMap = array()
protected

Definition at line 222 of file Abstract.php.

◆ $_rowClass

$_rowClass = 'Zend_Db_Table_Row'
protected

Definition at line 195 of file Abstract.php.

◆ $_rowsetClass

$_rowsetClass = 'Zend_Db_Table_Rowset'
protected

Definition at line 202 of file Abstract.php.

◆ $_schema

$_schema = null
protected

Definition at line 124 of file Abstract.php.

◆ $_sequence

$_sequence = true
protected

Definition at line 168 of file Abstract.php.

◆ ADAPTER

const ADAPTER = 'db'

Definition at line 50 of file Abstract.php.

◆ CASCADE

const CASCADE = 'cascade'

Definition at line 72 of file Abstract.php.

◆ CASCADE_RECURSE

const CASCADE_RECURSE = 'cascadeRecurse'

Definition at line 73 of file Abstract.php.

◆ COLS

const COLS = 'cols'

Definition at line 56 of file Abstract.php.

◆ COLUMNS

const COLUMNS = 'columns'

Definition at line 66 of file Abstract.php.

◆ DEFAULT_CLASS

const DEFAULT_CLASS = 'defaultClass'

Definition at line 78 of file Abstract.php.

◆ DEFAULT_DB

const DEFAULT_DB = 'defaultDb'

Definition at line 79 of file Abstract.php.

◆ DEFAULT_NONE

const DEFAULT_NONE = 'defaultNone'

Definition at line 77 of file Abstract.php.

◆ DEFINITION

const DEFINITION = 'definition'

Definition at line 51 of file Abstract.php.

◆ DEFINITION_CONFIG_NAME

const DEFINITION_CONFIG_NAME = 'definitionConfigName'

Definition at line 52 of file Abstract.php.

◆ DEPENDENT_TABLES

const DEPENDENT_TABLES = 'dependentTables'

Definition at line 63 of file Abstract.php.

◆ METADATA

const METADATA = 'metadata'

Definition at line 57 of file Abstract.php.

◆ METADATA_CACHE

const METADATA_CACHE = 'metadataCache'

Definition at line 58 of file Abstract.php.

◆ METADATA_CACHE_IN_CLASS

const METADATA_CACHE_IN_CLASS = 'metadataCacheInClass'

Definition at line 59 of file Abstract.php.

◆ NAME

const NAME = 'name'

Definition at line 54 of file Abstract.php.

◆ ON_DELETE

const ON_DELETE = 'onDelete'

Definition at line 69 of file Abstract.php.

◆ ON_UPDATE

const ON_UPDATE = 'onUpdate'

Definition at line 70 of file Abstract.php.

◆ PRIMARY

const PRIMARY = 'primary'

Definition at line 55 of file Abstract.php.

◆ REF_COLUMNS

const REF_COLUMNS = 'refColumns'

Definition at line 68 of file Abstract.php.

◆ REF_TABLE_CLASS

const REF_TABLE_CLASS = 'refTableClass'

Definition at line 67 of file Abstract.php.

◆ REFERENCE_MAP

const REFERENCE_MAP = 'referenceMap'

Definition at line 62 of file Abstract.php.

◆ RESTRICT

const RESTRICT = 'restrict'

Definition at line 74 of file Abstract.php.

◆ ROW_CLASS

const ROW_CLASS = 'rowClass'

Definition at line 60 of file Abstract.php.

◆ ROWSET_CLASS

const ROWSET_CLASS = 'rowsetClass'

Definition at line 61 of file Abstract.php.

◆ SCHEMA

const SCHEMA = 'schema'

Definition at line 53 of file Abstract.php.

◆ SELECT_WITH_FROM_PART

const SELECT_WITH_FROM_PART = true

Definition at line 81 of file Abstract.php.

◆ SELECT_WITHOUT_FROM_PART

const SELECT_WITHOUT_FROM_PART = false

Definition at line 82 of file Abstract.php.

◆ SEQUENCE

const SEQUENCE = 'sequence'

Definition at line 64 of file Abstract.php.

◆ SET_NULL

const SET_NULL = 'setNull'

Definition at line 75 of file Abstract.php.


The documentation for this class was generated from the following file: