import v1.1.0_beta1 | 2009-08-21

This commit is contained in:
2019-07-17 22:16:19 +02:00
parent 2c1152f0d3
commit 8dee6b1a10
2306 changed files with 251360 additions and 23428 deletions

View File

@ -325,6 +325,37 @@ abstract class Zend_Db_Table_Abstract
return $this->_rowsetClass;
}
/**
* Add a reference to the reference map
*
* @param string $ruleKey
* @param string|array $columns
* @param string $refTableClass
* @param string|array $refColumns
* @param string $onDelete
* @param string $onUpdate
* @return Zend_Db_Table_Abstract
*/
public function addReference($ruleKey, $columns, $refTableClass, $refColumns,
$onDelete = null, $onUpdate = null)
{
$reference = array(self::COLUMNS => (array) $columns,
self::REF_TABLE_CLASS => $refTableClass,
self::REF_COLUMNS => (array) $refColumns);
if (!empty($onDelete)) {
$reference[self::ON_DELETE] = $onDelete;
}
if (!empty($onUpdate)) {
$reference[self::ON_UPDATE] = $onUpdate;
}
$this->_referenceMap[$ruleKey] = $reference;
return $this;
}
/**
* @param array $referenceMap
* @return Zend_Db_Table_Abstract Provides a fluent interface
@ -546,10 +577,10 @@ abstract class Zend_Db_Table_Abstract
}
/**
* Indicate whether metadata should be cached in the class for the duration
* Indicate whether metadata should be cached in the class for the duration
* of the instance
*
* @param bool $flag
*
* @param bool $flag
* @return Zend_Db_Table_Abstract
*/
public function setMetadataCacheInClass($flag)
@ -559,9 +590,9 @@ abstract class Zend_Db_Table_Abstract
}
/**
* Retrieve flag indicating if metadata should be cached for duration of
* Retrieve flag indicating if metadata should be cached for duration of
* instance
*
*
* @return bool
*/
public function metadataCacheInClass()
@ -713,7 +744,7 @@ abstract class Zend_Db_Table_Abstract
/**
* Retrieve table columns
*
*
* @return array
*/
protected function _getCols()
@ -945,6 +976,29 @@ abstract class Zend_Db_Table_Abstract
return $pkData;
}
/**
* Check if the provided column is an identity of the table
*
* @param string $column
* @throws Zend_Db_Table_Exception
* @return boolean
*/
public function isIdentity($column)
{
$this->_setupPrimaryKey();
if (!isset($this->_metadata[$column])) {
/**
* @see Zend_Db_Table_Exception
*/
require_once 'Zend/Db/Table/Exception.php';
throw new Zend_Db_Table_Exception('Column "' . $column . '" not found in table.');
}
return (bool) $this->_metadata[$column]['IDENTITY'];
}
/**
* Updates existing rows.
*
@ -1105,11 +1159,11 @@ abstract class Zend_Db_Table_Abstract
$whereClause = null;
if (count($whereList)) {
$whereOrTerms = array();
$tableName = $this->_db->quoteTableAs($this->_name, null, true);
foreach ($whereList as $keyValueSets) {
$whereAndTerms = array();
foreach ($keyValueSets as $keyPosition => $keyValue) {
$type = $this->_metadata[$keyNames[$keyPosition]]['DATA_TYPE'];
$tableName = $this->_db->quoteTableAs($this->_name, null, true);
$columnName = $this->_db->quoteIdentifier($keyNames[$keyPosition], true);
$whereAndTerms[] = $this->_db->quoteInto(
$tableName . '.' . $columnName . ' = ?',
@ -1165,17 +1219,20 @@ abstract class Zend_Db_Table_Abstract
'stored' => true
);
@Zend_Loader::loadClass($this->_rowsetClass);
if (!class_exists($this->_rowsetClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_rowsetClass);
}
return new $this->_rowsetClass($data);
}
/**
* Fetches one row in an object of type Zend_Db_Table_Row_Abstract,
* or returns Boolean false if no row matches the specified criteria.
* or returns null if no row matches the specified criteria.
*
* @param string|array|Zend_Db_Table_Select $where OPTIONAL An SQL WHERE clause or Zend_Db_Table_Select object.
* @param string|array $order OPTIONAL An SQL ORDER clause.
* @return Zend_Db_Table_Row_Abstract The row results per the
* @return Zend_Db_Table_Row_Abstract|null The row results per the
* Zend_Db_Adapter fetch mode, or null if no row found.
*/
public function fetchRow($where = null, $order = null)
@ -1210,7 +1267,10 @@ abstract class Zend_Db_Table_Abstract
'stored' => true
);
@Zend_Loader::loadClass($this->_rowClass);
if (!class_exists($this->_rowClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_rowClass);
}
return new $this->_rowClass($data);
}
@ -1269,7 +1329,10 @@ abstract class Zend_Db_Table_Abstract
'stored' => false
);
@Zend_Loader::loadClass($this->_rowClass);
if (!class_exists($this->_rowClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_rowClass);
}
$row = new $this->_rowClass($config);
$row->setFromArray($data);
return $row;

View File

@ -25,11 +25,6 @@
*/
require_once 'Zend/Db.php';
/**
* @see Zend_Loader
*/
require_once 'Zend/Loader.php';
/**
* @category Zend
* @package Zend_Db
@ -121,6 +116,12 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
if (isset($config['table']) && $config['table'] instanceof Zend_Db_Table_Abstract) {
$this->_table = $config['table'];
$this->_tableClass = get_class($this->_table);
} else if ($this->_tableClass !== null) {
if (!class_exists($this->_tableClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_tableClass);
}
$this->_table = new $this->_tableClass();
}
if (isset($config['data'])) {
@ -203,6 +204,28 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$this->_modifiedFields[$columnName] = true;
}
/**
* Unset row field value
*
* @param string $columnName The column key.
* @return Zend_Db_Table_Row_Abstract
* @throws Zend_Db_Table_Row_Exception
*/
public function __unset($columnName)
{
$columnName = $this->_transformColumn($columnName);
if (!array_key_exists($columnName, $this->_data)) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is not in the row");
}
if ($this->isConnected() && in_array($columnName, $this->_table->info('primary'))) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception("Specified column \"$columnName\" is a primary key and should not be unset");
}
unset($this->_data[$columnName]);
return $this;
}
/**
* Test existence of row field
*
@ -453,7 +476,9 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
if (is_array($primaryKey)) {
$newPrimaryKey = $primaryKey;
} else {
$newPrimaryKey = array(current((array) $this->_primary) => $primaryKey);
//ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails.
$tempPrimaryKey = (array) $this->_primary;
$newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey);
}
/**
@ -524,11 +549,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$pkNew = $this->_getPrimaryKey(true);
$pkOld = $this->_getPrimaryKey(false);
foreach ($depTables as $tableClass) {
try {
@Zend_Loader::loadClass($tableClass);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
if (!class_exists($tableClass)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($tableClass);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
}
}
$t = new $tableClass(array('db' => $db));
$t->_cascadeUpdate($this->getTableClass(), $pkOld, $pkNew);
@ -602,11 +630,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$db = $this->_getTable()->getAdapter();
$pk = $this->_getPrimaryKey();
foreach ($depTables as $tableClass) {
try {
@Zend_Loader::loadClass($tableClass);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
if (!class_exists($tableClass)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($tableClass);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
}
}
$t = new $tableClass(array('db' => $db));
$t->_cascadeDelete($this->getTableClass(), $pk);
@ -855,11 +886,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$db = $this->_getTable()->getAdapter();
if (is_string($dependentTable)) {
try {
@Zend_Loader::loadClass($dependentTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
if (!class_exists($dependentTable)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($dependentTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
}
}
$dependentTable = new $dependentTable(array('db' => $db));
}
@ -900,6 +934,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
*
* @param string|Zend_Db_Table_Abstract $parentTable
* @param string OPTIONAL $ruleKey
* @param Zend_Db_Table_Select OPTIONAL $select
* @return Zend_Db_Table_Row_Abstract Query result from $parentTable
* @throws Zend_Db_Table_Row_Exception If $parentTable is not a table or is not loadable.
*/
@ -908,11 +943,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$db = $this->_getTable()->getAdapter();
if (is_string($parentTable)) {
try {
@Zend_Loader::loadClass($parentTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
if (!class_exists($parentTable)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($parentTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
}
}
$parentTable = new $parentTable(array('db' => $db));
}
@ -951,8 +989,9 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
/**
* @param string|Zend_Db_Table_Abstract $matchTable
* @param string|Zend_Db_Table_Abstract $intersectionTable
* @param string OPTIONAL $primaryRefRule
* @param string OPTIONAL $callerRefRule
* @param string OPTIONAL $matchRefRule
* @param Zend_Db_Table_Select OPTIONAL $select
* @return Zend_Db_Table_Rowset_Abstract Query result from $matchTable
* @throws Zend_Db_Table_Row_Exception If $matchTable or $intersectionTable is not a table class or is not loadable.
*/
@ -962,11 +1001,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$db = $this->_getTable()->getAdapter();
if (is_string($intersectionTable)) {
try {
@Zend_Loader::loadClass($intersectionTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
if (!class_exists($intersectionTable)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($intersectionTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
}
}
$intersectionTable = new $intersectionTable(array('db' => $db));
}
@ -980,11 +1022,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
}
if (is_string($matchTable)) {
try {
@Zend_Loader::loadClass($matchTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
if (!class_exists($matchTable)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($matchTable);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
}
}
$matchTable = new $matchTable(array('db' => $db));
}
@ -1007,8 +1052,10 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
$interInfo = $intersectionTable->info();
$interDb = $intersectionTable->getAdapter();
$interName = $interInfo['name'];
$interSchema = isset($interInfo['schema']) ? $interInfo['schema'] : null;
$matchInfo = $matchTable->info();
$matchName = $matchInfo['name'];
$matchSchema = isset($matchInfo['schema']) ? $matchInfo['schema'] : null;
$matchMap = $this->_prepareReference($intersectionTable, $matchTable, $matchRefRule);
@ -1019,8 +1066,8 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
}
$joinCond = implode(' AND ', $joinCond);
$select->from(array('i' => $interName))
->joinInner(array('m' => $matchName), $joinCond)
$select->from(array('i' => $interName), Zend_Db_Select::SQL_WILDCARD, $interSchema)
->joinInner(array('m' => $matchName), $joinCond, Zend_Db_Select::SQL_WILDCARD, $matchSchema)
->setIntegrityCheck(false);
$callerMap = $this->_prepareReference($intersectionTable, $this->_getTable(), $callerRefRule);
@ -1046,11 +1093,14 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
);
$rowsetClass = $matchTable->getRowsetClass();
try {
@Zend_Loader::loadClass($rowsetClass);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
if (!class_exists($rowsetClass)) {
try {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($rowsetClass);
} catch (Zend_Exception $e) {
require_once 'Zend/Db/Table/Row/Exception.php';
throw new Zend_Db_Table_Row_Exception($e->getMessage());
}
}
$rowset = new $rowsetClass($config);
return $rowset;

View File

@ -20,11 +20,6 @@
* @version $Id: Abstract.php 5896 2007-07-27 20:04:24Z bkarwin $
*/
/**
* @see Zend_Loader
*/
require_once 'Zend/Loader.php';
/**
* @category Zend
* @package Zend_Db
@ -116,7 +111,10 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
if (isset($config['rowClass'])) {
$this->_rowClass = $config['rowClass'];
}
@Zend_Loader::loadClass($this->_rowClass);
if (!class_exists($this->_rowClass)) {
require_once 'Zend/Loader.php';
Zend_Loader::loadClass($this->_rowClass);
}
if (isset($config['data'])) {
$this->_data = $config['data'];
}
@ -129,7 +127,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
// set the count of rows
$this->_count = count($this->_data);
$this->init();
}
@ -310,7 +308,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
{
return $this->_count;
}
/**
* Take the Iterator to position $position
* Required by interface SeekableIterator.
@ -322,14 +320,14 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
public function seek($position)
{
$position = (int) $position;
if ($position < 0 || $position > $this->_count) {
if ($position < 0 || $position >= $this->_count) {
require_once 'Zend/Db/Table/Rowset/Exception.php';
throw new Zend_Db_Table_Rowset_Exception("Illegal index $position");
}
$this->_pointer = $position;
return $this;
return $this;
}
/**
* Check if an offset exists
* Required by the ArrayAccess implementation
@ -341,7 +339,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
{
return isset($this->_data[(int) $offset]);
}
/**
* Get the row for the given offset
* Required by the ArrayAccess implementation
@ -355,7 +353,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
return $this->current();
}
/**
* Does nothing
* Required by the ArrayAccess implementation
@ -366,7 +364,7 @@ abstract class Zend_Db_Table_Rowset_Abstract implements SeekableIterator, Counta
public function offsetSet($offset, $value)
{
}
/**
* Does nothing
* Required by the ArrayAccess implementation

View File

@ -65,7 +65,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select
* @var Zend_Db_Table_Abstract
*/
protected $_table;
/**
* Class constructor
*
@ -74,6 +74,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select
public function __construct(Zend_Db_Table_Abstract $table)
{
parent::__construct($table->getAdapter());
$this->setTable($table);
}
@ -86,7 +87,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select
{
return $this->_table;
}
/**
* Sets the primary table name and retrieves the table schema.
*
@ -98,7 +99,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select
$this->_adapter = $table->getAdapter();
$this->_info = $table->info();
$this->_table = $table;
return $this;
}
@ -139,7 +140,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select
if ($alias !== null) {
$column = $alias;
}
switch (true) {
case ($column == self::SQL_WILDCARD):
break;
@ -159,8 +160,8 @@ class Zend_Db_Table_Select extends Zend_Db_Select
*
* The table name can be expressed
*
* @param array|string|Zend_Db_Expr|Zend_Db_Table_Abstract $name The table name or an
associative array relating
* @param array|string|Zend_Db_Expr|Zend_Db_Table_Abstract $name The table name or an
associative array relating
table name to correlation
name.
* @param array|string|Zend_Db_Expr $cols The columns to select from this table.
@ -203,7 +204,7 @@ class Zend_Db_Table_Select extends Zend_Db_Select
if ($this->_integrityCheck !== false) {
foreach ($fields as $columnEntry) {
list($table, $column) = $columnEntry;
// Check each column to ensure it only references the primary table
if ($column) {
if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
@ -216,4 +217,4 @@ class Zend_Db_Table_Select extends Zend_Db_Select
return parent::assemble();
}
}
}