예제 #1
0
 /**
  * @param modelResultSet $resultSet 
  */
 public static function cache($resultSet, $results = null, $count = false)
 {
     if (!$resultSet->isCacheEnabled()) {
         return;
     }
     $lifetime = $resultSet->getCacheLifetime();
     if ($lifetime === null) {
         $lifetime = 300;
     }
     $cacheKey = md5($count ? $resultSet->getCountSql() : $resultSet->getSql());
     if ($results === null) {
         $results = array();
         foreach ($resultSet as $result) {
             $results[] = $result;
         }
     }
     // try to use Memcache
     if ($memcache = self::getMemcache()) {
         if ($memcache->set($cacheKey, $results, false, $lifetime)) {
             return;
         }
     }
     self::$_cache[$cacheKey] = $results;
 }
예제 #2
0
 public function select()
 {
     $args = func_get_args();
     $fields = false;
     $aggregation = false;
     foreach ($args as $arg) {
         if ($arg instanceof modelField) {
             if ($arg->getCollection()->getTableName() == $this->getTableName()) {
                 $fields = true;
             }
         }
         if ($arg instanceof modelAggregation) {
             $aggregation = true;
         }
     }
     if (!$fields && !$aggregation) {
         array_unshift($args, $this);
     }
     $result = new modelResultSet();
     $result->setStorageSource($this);
     call_user_func_array(array($result, 'select'), $args);
     return $result;
 }
예제 #3
0
 public function rewind()
 {
     $this->_resultSet->reset();
     return $this->_fetch();
 }