コード例 #1
0
 public function findByPost(Post $post, $taxonomy = null, $hydrationMode = AbstractQuery::HYDRATE_SIMPLEOBJECT)
 {
     $queryBuilder = $this->getQueryBuilder()->join('t.taxonomy', 'taxonomy')->join('taxonomy.posts', 'post')->andWhere('post.id = :postId')->setParameter('postId', $post->getId());
     if (null !== $taxonomy) {
         $queryBuilder->andWhere('taxonomy.name = :taxonomyName')->setParameter('taxonomyName', is_string($taxonomy) ? $taxonomy : $taxonomy->getName());
     }
     return $queryBuilder->getQuery()->getResult($hydrationMode);
 }
コード例 #2
0
 public function getMetaByPost(Post $post, $key, $hydrationMode = AbstractQuery::HYDRATE_SIMPLEOBJECT)
 {
     return $this->getQueryBuilder()->join('pm.post', 'post')->andWhere('post.id = :postId')->andWhere('pm.key = :key')->setMaxResults(1)->setParameter('postId', $post->getId())->setParameter('key', $key)->getQuery()->getOneOrNullResult($hydrationMode);
 }