コード例 #1
0
 protected function execute(ICollection $collection, IEntity $parent)
 {
     $collectionMapper = $collection->getCollectionMapper();
     if (!$collectionMapper instanceof CollectionMapper) {
         throw new LogicException();
     }
     $builder = $collectionMapper->getSqlBuilder();
     $preloadIterator = $parent->getPreloadContainer();
     $values = $preloadIterator ? $preloadIterator->getPreloadValues($this->metadata->name) : [$parent->getRawValue($this->metadata->name)];
     $cacheKey = md5($builder->buildSelectQuery() . json_encode($values));
     $data =& $this->cacheEntityContainers[$cacheKey];
     if ($data) {
         return $data;
     }
     $data = $this->fetch(clone $builder, stripos($cacheKey, 'JOIN') !== FALSE, $values);
     return $data;
 }
コード例 #2
0
 protected function executeCounts(ICollection $collection, IEntity $parent)
 {
     $collectionMapper = $collection->getCollectionMapper();
     if (!$collectionMapper instanceof CollectionMapper) {
         throw new LogicException();
     }
     $builder = $collectionMapper->getSqlBuilder();
     $preloadIterator = $parent->getPreloadContainer();
     $values = $preloadIterator ? $preloadIterator->getPreloadValues('id') : [$parent->id];
     $cacheKey = $this->calculateCacheKey($builder, $values);
     $data =& $this->cacheCounts[$cacheKey];
     if ($data !== NULL) {
         return $data;
     }
     $data = $this->fetchCounts($builder, $values);
     return $data;
 }
コード例 #3
0
 public function getIterator(IEntity $parent, ICollection $collection)
 {
     $data = $collection->findById($parent->{$this->metadata->name}->getInjectedValue())->fetchAll();
     return new EntityIterator($data);
 }
コード例 #4
0
 public function getIterator(IEntity $parent, ICollection $collection)
 {
     $key = $parent->getForeignKey($this->metadata->name);
     return [$key ? $collection->getById($key) : NULL];
 }
コード例 #5
0
 public function getIterator(IEntity $parent, ICollection $collection)
 {
     $data = $collection->findBy(["this->{$this->joinStorageKey}->id" => $parent->id])->fetchAll();
     return new EntityIterator($data);
 }
コード例 #6
0
ファイル: HasMany.php プロジェクト: Zarganwar/orm
 protected function applyDefaultOrder(ICollection $collection)
 {
     if (isset($this->metadata->args->relationship['order'])) {
         return $collection->orderBy($this->metadata->args->relationship['order'][0], $this->metadata->args->relationship['order'][1]);
     } else {
         return $collection;
     }
 }