import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -93,14 +93,14 @@ abstract class Zend_Db_Table_Abstract
|
||||
* @var unknown_type
|
||||
*/
|
||||
protected $_definition = null;
|
||||
|
||||
|
||||
/**
|
||||
* Optional definition config name used in concrete implementation
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_definitionConfigName = null;
|
||||
|
||||
|
||||
/**
|
||||
* Default cache for information provided by the adapter's describeTable() method.
|
||||
*
|
||||
@ -326,7 +326,7 @@ abstract class Zend_Db_Table_Abstract
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setDefinition()
|
||||
*
|
||||
@ -338,7 +338,7 @@ abstract class Zend_Db_Table_Abstract
|
||||
$this->_definition = $definition;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getDefinition()
|
||||
*
|
||||
@ -348,7 +348,7 @@ abstract class Zend_Db_Table_Abstract
|
||||
{
|
||||
return $this->_definition;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setDefinitionConfigName()
|
||||
*
|
||||
@ -360,7 +360,7 @@ abstract class Zend_Db_Table_Abstract
|
||||
$this->_definitionConfigName = $definitionConfigName;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getDefinitionConfigName()
|
||||
*
|
||||
@ -803,7 +803,16 @@ abstract class Zend_Db_Table_Abstract
|
||||
// If $this has a metadata cache
|
||||
if (null !== $this->_metadataCache) {
|
||||
// Define the cache identifier where the metadata are saved
|
||||
$cacheId = md5("$this->_schema.$this->_name");
|
||||
|
||||
//get db configuration
|
||||
$dbConfig = $this->_db->getConfig();
|
||||
|
||||
// Define the cache identifier where the metadata are saved
|
||||
$cacheId = md5( // port:host/dbname:schema.table (based on availabilty)
|
||||
(isset($dbConfig['options']['port']) ? ':'.$dbConfig['options']['port'] : null)
|
||||
. (isset($dbConfig['options']['host']) ? ':'.$dbConfig['options']['host'] : null)
|
||||
. '/'.$dbConfig['dbname'].':'.$this->_schema.'.'.$this->_name
|
||||
);
|
||||
}
|
||||
|
||||
// If $this has no metadata cache or metadata cache misses
|
||||
@ -969,8 +978,8 @@ abstract class Zend_Db_Table_Abstract
|
||||
self::COLS => $this->_getCols(),
|
||||
self::PRIMARY => (array) $this->_primary,
|
||||
self::METADATA => $this->_metadata,
|
||||
self::ROW_CLASS => $this->_rowClass,
|
||||
self::ROWSET_CLASS => $this->_rowsetClass,
|
||||
self::ROW_CLASS => $this->getRowClass(),
|
||||
self::ROWSET_CLASS => $this->getRowsetClass(),
|
||||
self::REFERENCE_MAP => $this->_referenceMap,
|
||||
self::DEPENDENT_TABLES => $this->_dependentTables,
|
||||
self::SEQUENCE => $this->_sequence
|
||||
@ -1228,6 +1237,7 @@ abstract class Zend_Db_Table_Abstract
|
||||
$whereList = array();
|
||||
$numberTerms = 0;
|
||||
foreach ($args as $keyPosition => $keyValues) {
|
||||
$keyValuesCount = count($keyValues);
|
||||
// Coerce the values to an array.
|
||||
// Don't simply typecast to array, because the values
|
||||
// might be Zend_Db_Expr objects.
|
||||
@ -1235,12 +1245,13 @@ abstract class Zend_Db_Table_Abstract
|
||||
$keyValues = array($keyValues);
|
||||
}
|
||||
if ($numberTerms == 0) {
|
||||
$numberTerms = count($keyValues);
|
||||
} else if (count($keyValues) != $numberTerms) {
|
||||
$numberTerms = $keyValuesCount;
|
||||
} else if ($keyValuesCount != $numberTerms) {
|
||||
require_once 'Zend/Db/Table/Exception.php';
|
||||
throw new Zend_Db_Table_Exception("Missing value(s) for the primary key");
|
||||
}
|
||||
for ($i = 0; $i < count($keyValues); ++$i) {
|
||||
$keyValues = array_values($keyValues);
|
||||
for ($i = 0; $i < $keyValuesCount; ++$i) {
|
||||
if (!isset($whereList[$i])) {
|
||||
$whereList[$i] = array();
|
||||
}
|
||||
@ -1266,6 +1277,16 @@ abstract class Zend_Db_Table_Abstract
|
||||
$whereClause = '(' . implode(' OR ', $whereOrTerms) . ')';
|
||||
}
|
||||
|
||||
// issue ZF-5775 (empty where clause should return empty rowset)
|
||||
if ($whereClause == null) {
|
||||
$rowsetClass = $this->getRowsetClass();
|
||||
if (!class_exists($rowsetClass)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($rowsetClass);
|
||||
}
|
||||
return new $rowsetClass(array('table' => $this, 'rowClass' => $this->getRowClass(), 'stored' => true));
|
||||
}
|
||||
|
||||
return $this->fetchAll($whereClause);
|
||||
}
|
||||
|
||||
@ -1307,15 +1328,16 @@ abstract class Zend_Db_Table_Abstract
|
||||
'table' => $this,
|
||||
'data' => $rows,
|
||||
'readOnly' => $select->isReadOnly(),
|
||||
'rowClass' => $this->_rowClass,
|
||||
'rowClass' => $this->getRowClass(),
|
||||
'stored' => true
|
||||
);
|
||||
|
||||
if (!class_exists($this->_rowsetClass)) {
|
||||
$rowsetClass = $this->getRowsetClass();
|
||||
if (!class_exists($rowsetClass)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($this->_rowsetClass);
|
||||
Zend_Loader::loadClass($rowsetClass);
|
||||
}
|
||||
return new $this->_rowsetClass($data);
|
||||
return new $rowsetClass($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1359,11 +1381,12 @@ abstract class Zend_Db_Table_Abstract
|
||||
'stored' => true
|
||||
);
|
||||
|
||||
if (!class_exists($this->_rowClass)) {
|
||||
$rowClass = $this->getRowClass();
|
||||
if (!class_exists($rowClass)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($this->_rowClass);
|
||||
Zend_Loader::loadClass($rowClass);
|
||||
}
|
||||
return new $this->_rowClass($data);
|
||||
return new $rowClass($data);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1421,11 +1444,12 @@ abstract class Zend_Db_Table_Abstract
|
||||
'stored' => false
|
||||
);
|
||||
|
||||
if (!class_exists($this->_rowClass)) {
|
||||
$rowClass = $this->getRowClass();
|
||||
if (!class_exists($rowClass)) {
|
||||
require_once 'Zend/Loader.php';
|
||||
Zend_Loader::loadClass($this->_rowClass);
|
||||
Zend_Loader::loadClass($rowClass);
|
||||
}
|
||||
$row = new $this->_rowClass($config);
|
||||
$row = new $rowClass($config);
|
||||
$row->setFromArray($data);
|
||||
return $row;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Definition.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Definition.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -31,12 +31,12 @@
|
||||
*/
|
||||
class Zend_Db_Table_Definition
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_tableConfigs = array();
|
||||
|
||||
|
||||
/**
|
||||
* __construct()
|
||||
*
|
||||
@ -50,7 +50,7 @@ class Zend_Db_Table_Definition
|
||||
$this->setOptions($options);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setConfig()
|
||||
*
|
||||
@ -62,7 +62,7 @@ class Zend_Db_Table_Definition
|
||||
$this->setOptions($config->toArray());
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setOptions()
|
||||
*
|
||||
@ -76,7 +76,7 @@ class Zend_Db_Table_Definition
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param string $tableName
|
||||
* @param array $tableConfig
|
||||
@ -87,15 +87,15 @@ class Zend_Db_Table_Definition
|
||||
// @todo logic here
|
||||
$tableConfig[Zend_Db_Table::DEFINITION_CONFIG_NAME] = $tableName;
|
||||
$tableConfig[Zend_Db_Table::DEFINITION] = $this;
|
||||
|
||||
|
||||
if (!isset($tableConfig[Zend_Db_Table::NAME])) {
|
||||
$tableConfig[Zend_Db_Table::NAME] = $tableName;
|
||||
}
|
||||
|
||||
|
||||
$this->_tableConfigs[$tableName] = $tableConfig;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getTableConfig()
|
||||
*
|
||||
@ -106,7 +106,7 @@ class Zend_Db_Table_Definition
|
||||
{
|
||||
return $this->_tableConfigs[$tableName];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* removeTableConfig()
|
||||
*
|
||||
@ -116,7 +116,7 @@ class Zend_Db_Table_Definition
|
||||
{
|
||||
unset($this->_tableConfigs[$tableName]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* hasTableConfig()
|
||||
*
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Table
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Abstract.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Abstract.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -472,9 +472,9 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
if (is_array($primaryKey)) {
|
||||
$newPrimaryKey = $primaryKey;
|
||||
} else {
|
||||
//ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails.
|
||||
//ZF-6167 Use tempPrimaryKey temporary to avoid that zend encoding fails.
|
||||
$tempPrimaryKey = (array) $this->_primary;
|
||||
$newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey);
|
||||
$newPrimaryKey = array(current($tempPrimaryKey) => $primaryKey);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -865,7 +865,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
if (is_string($dependentTable)) {
|
||||
$dependentTable = $this->_getTableFromString($dependentTable);
|
||||
}
|
||||
|
||||
|
||||
if (!$dependentTable instanceof Zend_Db_Table_Abstract) {
|
||||
$type = gettype($dependentTable);
|
||||
if ($type == 'object') {
|
||||
@ -921,7 +921,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
if (is_string($parentTable)) {
|
||||
$parentTable = $this->_getTableFromString($parentTable);
|
||||
}
|
||||
|
||||
|
||||
if (!$parentTable instanceof Zend_Db_Table_Abstract) {
|
||||
$type = gettype($parentTable);
|
||||
if ($type == 'object') {
|
||||
@ -937,7 +937,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
&& ($parentTable->getDefinition() == null)) {
|
||||
$parentTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
|
||||
}
|
||||
|
||||
|
||||
if ($select === null) {
|
||||
$select = $parentTable->select();
|
||||
} else {
|
||||
@ -955,7 +955,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
$parentColumnName = $parentDb->foldCase($map[Zend_Db_Table_Abstract::REF_COLUMNS][$i]);
|
||||
$parentColumn = $parentDb->quoteIdentifier($parentColumnName, true);
|
||||
$parentInfo = $parentTable->info();
|
||||
|
||||
|
||||
// determine where part
|
||||
$type = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['DATA_TYPE'];
|
||||
$nullable = $parentInfo[Zend_Db_Table_Abstract::METADATA][$parentColumnName]['NULLABLE'];
|
||||
@ -966,7 +966,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
} else {
|
||||
$select->where("$parentColumn = ?", $value, $type);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $parentTable->fetchRow($select);
|
||||
@ -989,7 +989,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
if (is_string($intersectionTable)) {
|
||||
$intersectionTable = $this->_getTableFromString($intersectionTable);
|
||||
}
|
||||
|
||||
|
||||
if (!$intersectionTable instanceof Zend_Db_Table_Abstract) {
|
||||
$type = gettype($intersectionTable);
|
||||
if ($type == 'object') {
|
||||
@ -1005,11 +1005,11 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
&& ($intersectionTable->getDefinition() == null)) {
|
||||
$intersectionTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
|
||||
}
|
||||
|
||||
|
||||
if (is_string($matchTable)) {
|
||||
$matchTable = $this->_getTableFromString($matchTable);
|
||||
}
|
||||
|
||||
|
||||
if (! $matchTable instanceof Zend_Db_Table_Abstract) {
|
||||
$type = gettype($matchTable);
|
||||
if ($type == 'object') {
|
||||
@ -1025,7 +1025,7 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
&& ($matchTable->getDefinition() == null)) {
|
||||
$matchTable->setOptions(array(Zend_Db_Table_Abstract::DEFINITION => $tableDefinition));
|
||||
}
|
||||
|
||||
|
||||
if ($select === null) {
|
||||
$select = $matchTable->select();
|
||||
} else {
|
||||
@ -1164,12 +1164,12 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
|
||||
if ($this->_table instanceof Zend_Db_Table_Abstract) {
|
||||
$tableDefinition = $this->_table->getDefinition();
|
||||
|
||||
|
||||
if ($tableDefinition !== null && $tableDefinition->hasTableConfig($tableName)) {
|
||||
return new Zend_Db_Table($tableName, $tableDefinition);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// assume the tableName is the class name
|
||||
if (!class_exists($tableName)) {
|
||||
try {
|
||||
@ -1182,11 +1182,11 @@ abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess
|
||||
}
|
||||
|
||||
$options = array();
|
||||
|
||||
|
||||
if (($table = $this->_getTable())) {
|
||||
$options['db'] = $table->getAdapter();
|
||||
}
|
||||
|
||||
|
||||
if (isset($tableDefinition) && $tableDefinition !== null) {
|
||||
$options[Zend_Db_Table_Abstract::DEFINITION] = $tableDefinition;
|
||||
}
|
||||
|
@ -18,7 +18,7 @@
|
||||
* @subpackage Select
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Select.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Select.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
|
||||
@ -193,23 +193,27 @@ class Zend_Db_Table_Select extends Zend_Db_Select
|
||||
$primary = $this->_info[Zend_Db_Table_Abstract::NAME];
|
||||
$schema = $this->_info[Zend_Db_Table_Abstract::SCHEMA];
|
||||
|
||||
// If no fields are specified we assume all fields from primary table
|
||||
if (!count($fields)) {
|
||||
$this->from($primary, self::SQL_WILDCARD, $schema);
|
||||
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
|
||||
}
|
||||
|
||||
$from = $this->getPart(Zend_Db_Table_Select::FROM);
|
||||
if (count($this->_parts[self::UNION]) == 0) {
|
||||
|
||||
if ($this->_integrityCheck !== false) {
|
||||
foreach ($fields as $columnEntry) {
|
||||
list($table, $column) = $columnEntry;
|
||||
// If no fields are specified we assume all fields from primary table
|
||||
if (!count($fields)) {
|
||||
$this->from($primary, self::SQL_WILDCARD, $schema);
|
||||
$fields = $this->getPart(Zend_Db_Table_Select::COLUMNS);
|
||||
}
|
||||
|
||||
// Check each column to ensure it only references the primary table
|
||||
if ($column) {
|
||||
if (!isset($from[$table]) || $from[$table]['tableName'] != $primary) {
|
||||
require_once 'Zend/Db/Table/Select/Exception.php';
|
||||
throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
|
||||
$from = $this->getPart(Zend_Db_Table_Select::FROM);
|
||||
|
||||
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) {
|
||||
require_once 'Zend/Db/Table/Select/Exception.php';
|
||||
throw new Zend_Db_Table_Select_Exception('Select query cannot join with another table');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user