Index: /home/jordan/workspace/zend-framework/library/Zend/Db/Table/Row/Abstract.php =================================================================== --- /home/jordan/workspace/zend-framework/library/Zend/Db/Table/Row/Abstract.php (revision 7160) +++ /home/jordan/workspace/zend-framework/library/Zend/Db/Table/Row/Abstract.php (working copy) @@ -38,7 +38,7 @@ * @copyright Copyright (c) 2005-2007 Zend Technologies USA Inc. (http://www.zend.com) * @license http://framework.zend.com/license/new-bsd New BSD License */ -abstract class Zend_Db_Table_Row_Abstract +abstract class Zend_Db_Table_Row_Abstract implements ArrayAccess { /** @@ -150,16 +150,10 @@ * * @param string $columnName The user-specified column name. * @return string The corresponding column value. - * @throws Zend_Db_Table_Row_Exception if the $columnName is not a column in the row. */ public function __get($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"); - } - return $this->_data[$columnName]; + return $this->offsetGet($columnName); } /** @@ -168,16 +162,10 @@ * @param string $columnName The column key. * @param mixed $value The value for the property. * @return void - * @throws Zend_Db_Table_Row_Exception */ public function __set($columnName, $value) { - $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"); - } - $this->_data[$columnName] = $value; + return $this->offsetSet($columnName, $value); } /** @@ -188,8 +176,7 @@ */ public function __isset($columnName) { - $columnName = $this->_transformColumn($columnName); - return array_key_exists($columnName, $this->_data); + return $this->offsetExists($columnName); } /** @@ -215,6 +202,67 @@ } /** + * Test existence of row field + * + * @param string $columnName + * @return boolean + */ + public function offsetExists($columnName) + { + $columnName = $this->_transformColumn($columnName); + return array_key_exists($columnName, $this->_data); + } + + /** + * Retrieve row field value + * + * @param string $columnName The user-specified column name. + * @return string The corresponding column value. + * @throws Zend_Db_Table_Row_Exception if the $columnName is not a column in the row. + */ + public function offsetGet($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"); + } + return $this->_data[$columnName]; + } + + /** + * Set row field value + * + * @param string $columnName The column key. + * @param mixed $value The value for the property. + * @return void + * @throws Zend_Db_Table_Row_Exception + */ + public function offsetSet($columnName, $value) + { + $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"); + } + $this->_data[$columnName] = $value; + } + + /** + * Unsets the row field + * + * @param string $columnName + * @return void + */ + public function offsetUnset($columnName) + { + $columnName = $this->_transformColumn($columnName); + if (array_key_exists($columnName, $this->_data)) { + unset($this->_data[$columnName]); + } + } + + /** * Returns the table object, or null if this is disconnected row * * @return Zend_Db_Table_Abstract|null