Changeset 2332

Show
Ignore:
Timestamp:
11/08/2007 07:09:06 PM (14 months ago)
Author:
wei
Message:

TCache implements ArrayAccess?. duplicate copyFrom in TActiveRecord

Location:
trunk/framework
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/framework/Caching/TCache.php

    r1995 r2332  
    3939 * and optionally {@link flush} 
    4040 * 
     41 * Since version 3.1.2, TCache implements the ArrayAccess interface such that 
     42 * the cache acts as an array. 
     43 * 
    4144 * @author Qiang Xue <qiang.xue@gmail.com> 
    4245 * @version $Id$ 
     
    4447 * @since 3.0 
    4548 */ 
    46 abstract class TCache extends TModule implements ICache 
     49abstract class TCache extends TModule implements ICache, ArrayAccess 
    4750{ 
    4851        private $_prefix=null; 
     
    232235         */ 
    233236        abstract protected function deleteValue($key); 
     237 
     238        /** 
     239         * Returns whether there is a cache entry with a specified key. 
     240         * This method is required by the interface ArrayAccess. 
     241         * @param string a key identifying the cached value 
     242         * @return boolean 
     243         */ 
     244        public function offsetExists($id) 
     245        { 
     246                return $this->get($id) !== false; 
     247        } 
     248 
     249        /* 
     250         * Retrieves the value from cache with a specified key. 
     251         * This method is required by the interface ArrayAccess. 
     252         * @param string a key identifying the cached value 
     253         * @return mixed the value stored in cache, false if the value is not in the cache or expired. 
     254         */ 
     255        public function offsetGet($id) 
     256        { 
     257                return $this->get($id); 
     258        } 
     259 
     260        /* 
     261         * Stores the value identified by a key into cache. 
     262         * If the cache already contains such a key, the existing value will be 
     263         * replaced with the new ones. To add expiration and dependencies, use the set() method. 
     264         * This method is required by the interface ArrayAccess. 
     265         * @param string the key identifying the value to be cached 
     266         * @param mixed the value to be cached 
     267         */ 
     268        public function offsetSet($id, $value) 
     269        { 
     270                $this->set($id, $value); 
     271        } 
     272 
     273        /* 
     274         * Deletes the value with the specified key from cache 
     275         * This method is required by the interface ArrayAccess. 
     276         * @param string the key of the value to be deleted 
     277         * @return boolean if no error happens during deletion 
     278         */ 
     279        public function offsetUnset($id) 
     280        { 
     281                $this->delete($id); 
     282        } 
    234283} 
    235284 
  • trunk/framework/Data/ActiveRecord/TActiveRecord.php

    r2331 r2332  
    521521                $record=new $type($data); 
    522522                $record->_recordState=self::STATE_LOADED; 
    523                 $record->copyFrom($data); 
    524523                return $record; 
    525524        } 
  • trunk/framework/Data/DataGateway/TTableGateway.php

    r1902 r2332  
    117117                $meta = TDbMetaData::getInstance($this->getDbConnection()); 
    118118                $this->initCommandBuilder($meta->createCommandBuilder($tableName)); 
     119        } 
     120 
     121        public function getTableInfo() 
     122        { 
     123                return $this->getCommand()->getTableInfo(); 
     124        } 
     125 
     126        public function getTableName() 
     127        { 
     128                return $this->getTableInfo()->getTableName(); 
    119129        } 
    120130