From: Chuck Hagenbuch Date: Tue, 1 Jun 2010 02:56:11 +0000 (-0400) Subject: Add shortcuts for accessing columns in the Table, similar to TableDefinition X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=eb3a58fd8d3d75832f633df44cab9106c51d8a66;p=horde.git Add shortcuts for accessing columns in the Table, similar to TableDefinition --- diff --git a/framework/Db/lib/Horde/Db/Adapter/Base/Table.php b/framework/Db/lib/Horde/Db/Adapter/Base/Table.php index f0dfa0ca4..6e9cc5b48 100644 --- a/framework/Db/lib/Horde/Db/Adapter/Base/Table.php +++ b/framework/Db/lib/Horde/Db/Adapter/Base/Table.php @@ -21,7 +21,7 @@ * @package Horde_Db * @subpackage Adapter */ -class Horde_Db_Adapter_Base_Table +class Horde_Db_Adapter_Base_Table implements ArrayAccess, IteratorAggregate { protected $_name; protected $_primaryKey; @@ -117,6 +117,77 @@ class Horde_Db_Adapter_Base_Table /*########################################################################## + # Object composition + ##########################################################################*/ + + public function __get($key) + { + return $this->getColumn($key); + } + + public function __isset($key) + { + return isset($this->_columns[$key]); + } + + + /*########################################################################## + # ArrayAccess + ##########################################################################*/ + + /** + * ArrayAccess: Check if the given offset exists + * + * @param int $offset + * @return boolean + */ + public function offsetExists($offset) + { + return isset($this->_columns[$column]); + } + + /** + * ArrayAccess: Return the value for the given offset. + * + * @param int $offset + * @return object {@link {@Horde_Db_Adapter_Base_ColumnDefinition} + */ + public function offsetGet($offset) + { + return $this->getColumn($offset); + } + + /** + * ArrayAccess: Set value for given offset + * + * @param int $offset + * @param mixed $value + */ + public function offsetSet($offset, $value) + { + } + + /** + * ArrayAccess: remove element + * + * @param int $offset + */ + public function offsetUnset($offset) + { + } + + + /*########################################################################## + # IteratorAggregate + ##########################################################################*/ + + public function getIterator() + { + return new ArrayIterator($this->_columns); + } + + + /*########################################################################## # Protected ##########################################################################*/