本文整理汇总了PHP中Doctrine\ORM\EntityRepository::createQueryBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityRepository::createQueryBuilder方法的具体用法?PHP EntityRepository::createQueryBuilder怎么用?PHP EntityRepository::createQueryBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine\ORM\EntityRepository
的用法示例。
在下文中一共展示了EntityRepository::createQueryBuilder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildBaseQuery
/**
* @return QueryBuilder
*/
private function buildBaseQuery()
{
$qb = $this->entityRepository->createQueryBuilder('z');
GathererHelper::addFiltersDataToQuery($this->filters, $qb);
GathererHelper::addAdditionalFilterDataToQuery($this->additionalFilters, $qb);
return $qb;
}
示例2: findTopicsByCategory
/**
* {@inheritDoc}
*/
public function findTopicsByCategory(CategoryInterface $category, $page = 0)
{
$qb = $this->repository->createQueryBuilder('t')->select('t, c, u')->join('t.category', 'c')->join('t.user', 'u')->where('c.id = :category')->andWhere('t.isDeleted = 0')->orderBy('t.lastPost', 'desc')->setParameter('category', $category->getId());
$pager = new Pager(new ProxyQuery($qb));
$pager->setPage($page);
return $pager;
}
示例3: findPostsByTopic
/**
* {@inheritDoc}
*/
public function findPostsByTopic(TopicInterface $topic, $page = 1)
{
$qb = $this->repository->createQueryBuilder('p')->select('p, t, u')->join('p.topic', 't')->join('p.user', 'u')->where('t.id = :topic')->andWhere('p.isDeleted = 0')->orderBy('p.created', 'asc')->setParameter('topic', $topic->getId());
$pager = new Pager(new ProxyQuery($qb));
$pager->setLimit(25)->setPage($page);
return $pager;
}
示例4: addFilterByOrderStatus
/**
* @param QueryBuilder $qb
* @param string $orderStatus
*/
protected function addFilterByOrderStatus(QueryBuilder $qb, $orderStatus)
{
$aliases = $qb->getRootAliases();
$subQueryBuilder = $this->customerRepository->createQueryBuilder('c');
$subQueryBuilder->select('IDENTITY(c.account)')->join('c.orders', 'o', 'WITH', $subQueryBuilder->expr()->eq($subQueryBuilder->expr()->lower('o.status'), ':filteredOrderStatus'));
$qb->andWhere($qb->expr()->in($aliases[0] . '.account', $subQueryBuilder->getDQL()))->setParameter('filteredOrderStatus', $orderStatus);
}
示例5: createQueryBuilder
public function createQueryBuilder($alias = null, $indexBy = null)
{
if ($alias === null) {
$alias = $this->getName();
}
return $this->baseRepository->createQueryBuilder($alias, $indexBy);
}
示例6: findTextBySlugAndLocale
/**
* {@inheritdoc}
*/
public function findTextBySlugAndLocale($slug, $locale)
{
$qb = $this->repository->createQueryBuilder('text');
$qb->innerJoin('text.translations', 'translation', Join::WITH, $qb->expr()->eq('translation.lang', ':locale'))->setParameter('locale', $locale);
$qb->andWhere($qb->expr()->eq('text.slug', ':slug'))->setParameter('slug', $slug);
$qb->select('text, translation');
return $qb->getQuery()->getOneOrNullResult();
}
示例7: getBaseQuery
/**
* Возвращает базовый запрос на выборку
* @return \Doctrine\ORM\QueryBuilder
*/
private function getBaseQuery()
{
$result = $this->entityRepository->createQueryBuilder('currency');
if ($this->limit) {
$result->setMaxResults($this->limit);
}
return $result;
}
示例8: renderBlock
/**
* @param \Twig_Environment $twig
* @param string $alias
* @return \Twig_Template
* @throws \InvalidArgumentException
*/
public function renderBlock(\Twig_Environment $twig, $alias)
{
$block = $this->repo->createQueryBuilder('b')->where('b.alias = :alias')->setParameters(compact('alias'))->setMaxResults(1)->getQuery()->useResultCache(true)->setResultCacheId('cms_block.' . $alias)->getResult();
$block = current($block);
if (!$block) {
throw new \InvalidArgumentException(sprintf("CMS block '%s' could not be found", $alias));
}
return $twig->createTemplate($block->getContent());
}
示例9: getQuery
/**
* {@inheritdoc}
*/
public function getQuery()
{
if (!$this->query) {
$qb = $this->categoryRepository->createQueryBuilder('c');
$qb->orderBy('c.root')->addOrderBy('c.left');
$this->query = $qb->getQuery();
}
return $this->query;
}
示例10: find
/**
* {@inheritdoc}
*/
public function find()
{
$qb = $this->repository->createQueryBuilder('s');
$qb->leftJoin('s.seoMetadata', 'sm');
$qb->setMaxResults(1);
$qb->select('s, sm');
$q = $qb->getQuery();
$q->useResultCache(true, 3600, SiteInterface::SITE);
return $q->getOneOrNullResult();
}
示例11: findVisible
public function findVisible($organizer)
{
if (!$organizer instanceof UserInterface) {
$organizer = null;
}
$qb = $this->repo->createQueryBuilder('e');
$qb->join('e.calendar', 'c')->andWhere('e.organizer = :organizer')->orWhere('c.visibility = :calendarVisibility');
$qb->setParameters(array('organizer' => $organizer, 'calendarVisibility' => CalendarInterface::VISIBILITY_PUBLIC));
return $qb->getQuery()->execute();
}
示例12: testApply
/**
* @dataProvider provideApplyTestData
*/
public function testApply($properties, array $filterParameters, string $expected)
{
$request = Request::create('/api/dummies', 'GET', $filterParameters);
$requestStack = new RequestStack();
$requestStack->push($request);
$queryBuilder = $this->repository->createQueryBuilder('o');
$filter = new NumericFilter($this->managerRegistry, $requestStack, null, $properties);
$filter->apply($queryBuilder, new QueryNameGenerator(), $this->resourceClass);
$actual = $queryBuilder->getQuery()->getDQL();
$this->assertEquals($expected, $actual);
}
示例13: findCommentTreeByCommentId
/**
* {@inheritdoc}
*/
public function findCommentTreeByCommentId($commentId, $sorter = null)
{
$qb = $this->repository->createQueryBuilder('c');
$qb->join('c.thread', 't')->where('LOCATE(:path, CONCAT(\'/\', CONCAT(c.ancestors, \'/\'))) > 0')->orderBy('c.ancestors', 'ASC')->setParameter('path', "/{$commentId}/");
$comments = $qb->getQuery()->execute();
if (!$comments) {
return array();
}
$sorter = $this->sortingFactory->getSorter($sorter);
$trimParents = current($comments)->getAncestors();
return $this->organiseComments($comments, $sorter, $trimParents);
}
示例14: findNodeAllChildrenTranslationsByLang
/**
* {@inheritdoc}
*/
public function findNodeAllChildrenTranslationsByLang(NodeInterface $node, $lang)
{
$qb = $this->repository->createQueryBuilder('t');
$qb->innerJoin('t.node', 'n');
$qb->andWhere($qb->expr()->eq('t.lang', ':locale'));
$qb->setParameter('locale', $lang);
$qb->andWhere($qb->expr()->eq('n.root', ':root'))->setParameter('root', $node->getRoot());
$qb->andWhere($qb->expr()->gte('n.left', ':left'))->setParameter('left', $node->getLeft());
$qb->andWhere($qb->expr()->lte('n.right', ':right'))->setParameter('right', $node->getRight());
$qb->select('t');
return $qb->getQuery()->getResult();
}
示例15: findExistingNodeTypes
/**
* {@inheritdoc}
*/
public function findExistingNodeTypes(TreeInterface $tree)
{
$qb = $this->repository->createQueryBuilder('n');
$qb->andWhere($qb->expr()->eq('n.tree', ':tree'))->setParameter('tree', $tree);
$qb->andWhere($qb->expr()->isNotNull('n.type'));
$qb->select('DISTINCT n.type');
$result = array();
foreach ($qb->getQuery()->getResult() as $row) {
$result[] = $row['type'];
}
return $result;
}