diff options
Diffstat (limited to 'libs/Zend/Db/Table/Abstract.php')
-rw-r--r-- | libs/Zend/Db/Table/Abstract.php | 100 |
1 files changed, 52 insertions, 48 deletions
diff --git a/libs/Zend/Db/Table/Abstract.php b/libs/Zend/Db/Table/Abstract.php index e07ed22517..f0a6ea18d7 100644 --- a/libs/Zend/Db/Table/Abstract.php +++ b/libs/Zend/Db/Table/Abstract.php @@ -15,25 +15,25 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @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 21079 2010-02-18 18:15:49Z tech13 $ + * @version $Id: Abstract.php 17822 2009-08-26 00:03:56Z ralph $ */ /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Adapter/Abstract.php'; +require_once 'Zend/Db/Adapter/Abstract.php'; /** * @see Zend_Db_Adapter_Abstract */ -// require_once 'Zend/Db/Select.php'; +require_once 'Zend/Db/Select.php'; /** * @see Zend_Db */ -// require_once 'Zend/Db.php'; +require_once 'Zend/Db.php'; /** * Class for SQL table interface. @@ -41,7 +41,7 @@ * @category Zend * @package Zend_Db * @subpackage Table - * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) + * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ abstract class Zend_Db_Table_Abstract @@ -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() * @@ -466,11 +466,11 @@ abstract class Zend_Db_Table_Abstract $refMap = $this->_getReferenceMapNormalized(); if ($ruleKey !== null) { if (!isset($refMap[$ruleKey])) { - // require_once "Zend/Db/Table/Exception.php"; + require_once "Zend/Db/Table/Exception.php"; throw new Zend_Db_Table_Exception("No reference rule \"$ruleKey\" from table $thisClass to table $tableClassname"); } if ($refMap[$ruleKey][self::REF_TABLE_CLASS] != $tableClassname) { - // require_once "Zend/Db/Table/Exception.php"; + require_once "Zend/Db/Table/Exception.php"; throw new Zend_Db_Table_Exception("Reference rule \"$ruleKey\" does not reference table $tableClassname"); } return $refMap[$ruleKey]; @@ -480,7 +480,7 @@ abstract class Zend_Db_Table_Abstract return $reference; } } - // require_once "Zend/Db/Table/Exception.php"; + require_once "Zend/Db/Table/Exception.php"; throw new Zend_Db_Table_Exception("No reference from table $thisClass to table $tableClassname"); } @@ -603,11 +603,11 @@ abstract class Zend_Db_Table_Abstract return null; } if (is_string($db)) { - // require_once 'Zend/Registry.php'; + require_once 'Zend/Registry.php'; $db = Zend_Registry::get($db); } if (!$db instanceof Zend_Db_Adapter_Abstract) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; 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'); } return $db; @@ -698,11 +698,11 @@ abstract class Zend_Db_Table_Abstract return null; } if (is_string($metadataCache)) { - // require_once 'Zend/Registry.php'; + require_once 'Zend/Registry.php'; $metadataCache = Zend_Registry::get($metadataCache); } if (!$metadataCache instanceof Zend_Cache_Core) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; 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'); } return $metadataCache; @@ -750,7 +750,7 @@ abstract class Zend_Db_Table_Abstract if (! $this->_db) { $this->_db = self::getDefaultAdapter(); if (!$this->_db instanceof Zend_Db_Adapter_Abstract) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('No adapter found for ' . get_class($this)); } } @@ -803,10 +803,10 @@ 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 - + //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) @@ -823,7 +823,11 @@ abstract class Zend_Db_Table_Abstract $metadata = $this->_db->describeTable($this->_name, $this->_schema); // If $this has a metadata cache, then cache the metadata if (null !== $this->_metadataCache && !$this->_metadataCache->save($metadata, $cacheId)) { - trigger_error('Failed saving metadata to metadataCache', E_USER_NOTICE); + /** + * @see Zend_Db_Table_Exception + */ + require_once 'Zend/Db/Table/Exception.php'; + throw new Zend_Db_Table_Exception('Failed saving metadata to metadataCache'); } } @@ -872,7 +876,7 @@ abstract class Zend_Db_Table_Abstract // if no primary key was specified and none was found in the metadata // then throw an exception. if (empty($this->_primary)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('A table must have a primary key, but none was found'); } } else if (!is_array($this->_primary)) { @@ -884,7 +888,7 @@ abstract class Zend_Db_Table_Abstract $cols = $this->_getCols(); if (! array_intersect((array) $this->_primary, $cols) == (array) $this->_primary) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Primary key column(s) (" . implode(',', (array) $this->_primary) . ") are not columns in this table (" @@ -986,7 +990,7 @@ abstract class Zend_Db_Table_Abstract } if (!array_key_exists($key, $info)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('There is no table information for the key "' . $key . '"'); } @@ -1001,7 +1005,7 @@ abstract class Zend_Db_Table_Abstract */ public function select($withFromPart = self::SELECT_WITHOUT_FROM_PART) { - // require_once 'Zend/Db/Table/Select.php'; + require_once 'Zend/Db/Table/Select.php'; $select = new Zend_Db_Table_Select($this); if ($withFromPart == self::SELECT_WITH_FROM_PART) { $select->from($this->info(self::NAME), Zend_Db_Table_Select::SQL_WILDCARD, $this->info(self::SCHEMA)); @@ -1088,7 +1092,7 @@ abstract class Zend_Db_Table_Abstract /** * @see Zend_Db_Table_Exception */ - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception('Column "' . $column . '" not found in table.'); } @@ -1221,12 +1225,12 @@ abstract class Zend_Db_Table_Abstract $keyNames = array_values((array) $this->_primary); if (count($args) < count($keyNames)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Too few columns for the primary key"); } if (count($args) > count($keyNames)) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Too many columns for the primary key"); } @@ -1243,7 +1247,7 @@ abstract class Zend_Db_Table_Abstract if ($numberTerms == 0) { $numberTerms = $keyValuesCount; } else if ($keyValuesCount != $numberTerms) { - // require_once 'Zend/Db/Table/Exception.php'; + require_once 'Zend/Db/Table/Exception.php'; throw new Zend_Db_Table_Exception("Missing value(s) for the primary key"); } $keyValues = array_values($keyValues); @@ -1276,13 +1280,13 @@ abstract class Zend_Db_Table_Abstract // 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); - // } + 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); } @@ -1329,10 +1333,10 @@ abstract class Zend_Db_Table_Abstract ); $rowsetClass = $this->getRowsetClass(); - // if (!class_exists($rowsetClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowsetClass); - // } + if (!class_exists($rowsetClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowsetClass); + } return new $rowsetClass($data); } @@ -1378,10 +1382,10 @@ abstract class Zend_Db_Table_Abstract ); $rowClass = $this->getRowClass(); - // if (!class_exists($rowClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowClass); - // } + if (!class_exists($rowClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowClass); + } return new $rowClass($data); } @@ -1441,10 +1445,10 @@ abstract class Zend_Db_Table_Abstract ); $rowClass = $this->getRowClass(); - // if (!class_exists($rowClass)) { - // require_once 'Zend/Loader.php'; - // Zend_Loader::loadClass($rowClass); - // } + if (!class_exists($rowClass)) { + require_once 'Zend/Loader.php'; + Zend_Loader::loadClass($rowClass); + } $row = new $rowClass($config); $row->setFromArray($data); return $row; |