当前位置: 首页>>代码示例>>PHP>>正文


PHP EntityManagerInterface::createQueryBuilder方法代码示例

本文整理汇总了PHP中Doctrine\ORM\EntityManagerInterface::createQueryBuilder方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManagerInterface::createQueryBuilder方法的具体用法?PHP EntityManagerInterface::createQueryBuilder怎么用?PHP EntityManagerInterface::createQueryBuilder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine\ORM\EntityManagerInterface的用法示例。


在下文中一共展示了EntityManagerInterface::createQueryBuilder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: searchDestinationUser

 /**
  * {@inheritdoc}
  */
 public function searchDestinationUser(CallEventInterface $ce)
 {
     /** @var Call $call */
     $call = $ce->getCall();
     $qb = $this->em->createQueryBuilder();
     $query = $qb->select('u')->from('UserBundle:User', 'u')->leftJoin('u.groups', 'g')->leftJoin('u.contacts', 'c')->where('g.account = :account')->setParameter('account', $call->getAccount())->andWhere('c.sip LIKE :sip')->setParameter('sip', '%' . $ce->getDstNumber() . '%')->setMaxResults(1)->getQuery();
     return $query->getOneOrNullResult();
 }
开发者ID:Exanrus,项目名称:crm-bundle,代码行数:11,代码来源:SipManager.php

示例2: gc

 /**
  * Cleanup old sessions
  * @link http://php.net/manual/en/sessionhandlerinterface.gc.php
  * @param int $maxLifetime <p>
  * Sessions that have not updated for
  * the last maxLifetime seconds will be removed.
  * </p>
  * @return bool <p>
  * The return value (usually TRUE on success, FALSE on failure).
  * Note this value is returned internally to PHP for processing.
  * </p>
  * @since 5.4.0
  */
 public function gc($maxLifetime)
 {
     $qb = $this->entityManager->createQueryBuilder();
     $qb->delete(get_class($this->sessionDataClass), 's');
     $qb->where($qb->expr()->lt('s.lastHit', time() - $maxLifetime));
     $qb->getQuery()->execute();
     return true;
 }
开发者ID:firegate666,项目名称:doctrine-sessionhandler,代码行数:21,代码来源:SessionHandler.php

示例3: findAllWithCategories

 public function findAllWithCategories()
 {
     # Doctrine dokumentace: http://doctrine-orm.readthedocs.org/projects/doctrine-orm/en/latest/reference/query-builder.html#high-level-api-methods
     $queryBuilder = $this->entityManager->createQueryBuilder();
     $products = $queryBuilder->select('p.id, p.name, pc.name as categoryName')->from(Product::class, 'p')->join('p.categories', 'pc')->getQuery()->getResult(AbstractQuery::HYDRATE_ARRAY);
     // šetří výkon
     dump($products);
     die;
 }
开发者ID:TomasVotruba,项目名称:lekarna-se-skoli-doctrine,代码行数:9,代码来源:ProductRepository.php

示例4: __invoke

 public function __invoke(User $user)
 {
     $qb = $this->em->createQueryBuilder();
     $qb2 = $this->em->createQueryBuilder();
     $ids = $qb2->select('IDENTITY(u.group)')->from(User::class, 'u')->where('u.login = :login')->setParameter('login', $user->getLogin())->getQuery()->getArrayResult();
     return $qb->select('ug')->from(UserGroup::class, 'ug')->where($qb->expr()->in('ug.id', array_map(function ($el) {
         return current($el);
     }, $ids)))->orderBy('ug.name')->getQuery()->getResult();
 }
开发者ID:Gorik,项目名称:Doctrine2-Relations,代码行数:9,代码来源:GroupsByUser.php

示例5: __construct

 public function __construct(EntityManagerInterface $entityManager, $entityName = null, Query $query = null)
 {
     $this->entityManager = $entityManager;
     $this->entityName = $entityName;
     if (is_null($query) && is_string($entityName) && class_exists($entityName)) {
         $query = $this->entityManager->createQueryBuilder()->select('o')->from($this->entityName, 'o')->getQuery();
     }
     $this->query = $query;
 }
开发者ID:mathielen,项目名称:import-engine,代码行数:9,代码来源:DoctrineStorage.php

示例6: buildForm

 /**
  * @param FormBuilderInterface $builder
  * @param array $options
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $types = [Notice::DEFAULT_TYPE];
     // add user-defined types
     $result = $this->em->createQueryBuilder()->select('n.type')->from('AnimeDbAppBundle:Notice', 'n')->where('n.type IS NOT NULL')->groupBy('n.type')->getQuery()->getResult();
     foreach ($result as $row) {
         $types[] = $row['type'];
     }
     $builder->add('status', 'choice', ['choices' => [Notice::STATUS_CREATED => 'New', Notice::STATUS_SHOWN => 'Shown', Notice::STATUS_CLOSED => 'Closed'], 'required' => false])->add('type', 'choice', ['choices' => $this->getNormalLabels($types), 'required' => false])->setMethod('GET');
 }
开发者ID:anime-db,项目名称:catalog-bundle,代码行数:14,代码来源:Filter.php

示例7: getLeadsCountForForms

 /**
  * Method used to count leads for a specified day
  * @param $forms Array of forms
  * @param $minDate DateTime object
  * @return mixed
  */
 protected function getLeadsCountForForms($forms, $minDate)
 {
     foreach ($forms as $form) {
         $formIds[] = $form->getId();
     }
     // formated date time
     $formatedMinDate = $minDate->format('Y-m-d');
     // Count leads for the specified day
     $querybuilder = $this->entity_manager->createQueryBuilder();
     $querybuilder->select('count(l)')->from('TellawLeadsFactoryBundle:Leads', 'l')->where('l.form IN (:formIds)')->andWhere('l.createdAt BETWEEN :minDate AND :maxDate')->setParameter('formIds', $formIds)->setParameter('minDate', $formatedMinDate . " 00:00:00")->setParameter('maxDate', $formatedMinDate . " 23:59:59");
     $querybuilder = $this->excludeInternalLeads($querybuilder);
     return $querybuilder->getQuery()->getSingleScalarResult();
 }
开发者ID:tellaw,项目名称:leadsfactory,代码行数:19,代码来源:AlertUtils.php

示例8: findBySearch

 /**
  * {@inheritdoc}
  *
  * @return FamilyInterface[]
  */
 public function findBySearch($search = null, array $options = [])
 {
     $qb = $this->entityManager->createQueryBuilder()->select('f')->from($this->entityName, 'f');
     if (null !== $search && '' !== $search) {
         $qb->where('f.code like :search')->setParameter('search', '%' . $search . '%');
         if (isset($options['locale'])) {
             $qb->leftJoin('f.translations', 'ft');
             $qb->orWhere('ft.label like :search AND ft.locale = :locale');
             $qb->setParameter('search', '%' . $search . '%');
             $qb->setParameter('locale', $options['locale']);
         }
     }
     $qb = $this->applyQueryOptions($qb, $options);
     return $qb->getQuery()->getResult();
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:20,代码来源:FamilySearchableRepository.php

示例9: getMultiCount

 /**
  * Count the number of objects in a collection with the given values.
  *
  * @param string $collection
  * @param string $column
  * @param array  $values
  * @param array  $extra
  *
  * @return int
  */
 public function getMultiCount($collection, $column, array $values, array $extra = [])
 {
     $builder = $this->em->createQueryBuilder();
     $builder->select('count(e)')->from($collection, 'e');
     $builder->where($builder->expr()->in(":{$column}", ":{$column}"));
     foreach ($extra as $key => $extraValue) {
         $builder->andWhere("e.{$key} = :{$key}");
     }
     $query = $builder->getQuery();
     $query->setParameter($column, $values);
     foreach ($extra as $key => $extraValue) {
         $query->setParameter($key, $extraValue);
     }
     return $query->presence();
 }
开发者ID:rosstuck,项目名称:Laravel-Doctrine,代码行数:25,代码来源:DoctrinePresenceVerifier.php

示例10: findBySearchQb

 /**
  * @param string $search
  * @param array  $options
  *
  * @return QueryBuilder
  */
 protected function findBySearchQb($search, array $options)
 {
     //TODO: refactor on master because this is exactly the same that FamilySearchableRepository
     //TODO: and should be put in Akeneo\Bundle\StorageUtilsBundle\Doctrine\ORM\Repository\SearchableRepository
     $qb = $this->entityManager->createQueryBuilder()->select('a')->from($this->entityName, 'a');
     $options = $this->resolveOptions($options);
     if (null !== $search) {
         $qb->leftJoin('a.translations', 'at');
         $qb->where('a.code like :search')->setParameter('search', '%' . $search . '%');
         if (null !== ($localeCode = $options['locale'])) {
             $qb->orWhere('at.label like :search AND at.locale like :locale');
             $qb->setParameter('search', '%' . $search . '%');
             $qb->setParameter('locale', $localeCode);
         }
     }
     if (!empty($options['identifiers'])) {
         $qb->andWhere('a.code in (:codes)');
         $qb->setParameter('codes', $options['identifiers']);
     }
     if (!empty($options['excluded_identifiers'])) {
         $qb->andWhere('a.code not in (:codes)');
         $qb->setParameter('codes', $options['excluded_identifiers']);
     }
     if (null !== $options['limit']) {
         $qb->setMaxResults($options['limit']);
         if (null !== $options['page']) {
             $qb->setFirstResult($options['limit'] * ($options['page'] - 1));
         }
     }
     //TODO: this part is specific to attributes
     if ($options['exclude_unique']) {
         $qb->andWhere('a.unique = 0');
     }
     if (null !== $options['types']) {
         $qb->andWhere('a.attributeType in (:types)');
         $qb->setParameter('types', $options['types']);
     }
     $qb->leftJoin('a.group', 'ag');
     if (!empty($options['attribute_groups'])) {
         $qb->andWhere('ag.code in (:groups)');
         $qb->setParameter('groups', $options['attribute_groups']);
     }
     $qb->orderBy('ag.code');
     $qb->orderBy('ag.sortOrder');
     $qb->groupBy('a.id');
     return $qb;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:53,代码来源:AttributeSearchableRepository.php

示例11: search

 public function search()
 {
     //$finder = $this->container->get('fos_elastica.finder.search.articles');
     $bool = new Query\Bool();
     $multiMatch = new Query\MultiMatch();
     $multiMatch->setFields(['subjects', 'title', 'keywords', 'subtitle', 'citations.raw', 'journal.title', 'journal.subtitle']);
     $multiMatch->setType('phrase_prefix');
     $multiMatch->setQuery($this->getParam('term'));
     $bool->addMust($multiMatch);
     if ($this->filter) {
         foreach ($this->filter as $key => $filter) {
             $filterObj = new Query\Match();
             $this->applyFilter($filterObj, $key, $filter);
             $bool->addMust($filterObj);
         }
     }
     $missing = new Filter\Missing("issue");
     $not = new Filter\BoolNot($missing);
     $notQ = new Query\Filtered();
     $notQ->setFilter($not);
     $bool->addMust($notQ);
     $query = new Query();
     $query->setQuery($bool);
     $query->setFrom($this->getPage() * $this->getLimit());
     $query->setSize($this->getLimit());
     $aggregation = new Terms('journals');
     $aggregation->setField('journal.id');
     $aggregation->setOrder('_count', 'desc');
     $qb = $this->em->createQueryBuilder();
     $qb->select('count(r.id)')->from('OjsJournalBundle:Journal', 'r')->where($qb->expr()->eq('r.status', 3));
     $aggregation->setSize($qb->getQuery()->getSingleScalarResult());
     $query->addAggregation($aggregation);
     $aggregation = new Terms('authors');
     $aggregation->setField('articleAuthors.author.id');
     $aggregation->setOrder('_count', 'desc');
     $qb = $this->em->createQueryBuilder();
     $qb->select('count(r.id)')->from('OjsJournalBundle:Author', 'r');
     $aggregation->setSize($qb->getQuery()->getSingleScalarResult());
     $query->addAggregation($aggregation);
     $elasticaAdapter = new ElasticaAdapter($this->index, $query);
     $pagerFanta = new Pagerfanta($elasticaAdapter);
     $pagerFanta->setMaxPerPage($this->getLimit());
     $pagerFanta->setCurrentPage($this->getPage());
     /** @var ResultSet $search */
     $search = $pagerFanta->getCurrentPageResults();
     $result = $search->getResults();
     //$search->getResults();
     $this->pager = $pagerFanta;
     $transformer = new ElasticaToModelTransformer($this->registry, 'OjsJournalBundle:Article');
     $transformer->setPropertyAccessor($this->propertyAccessor);
     $this->result = $transformer->transform($result);
     $this->setCount($pagerFanta->getNbResults());
     $this->addAggregation('journal', $this->transform($search->getAggregation('journals')['buckets'], 'OjsJournalBundle:Journal'));
     $this->addAggregation('author', $this->transform($search->getAggregation('authors')['buckets'], 'OjsJournalBundle:Author'));
     return $this;
 }
开发者ID:necatikartal,项目名称:ojs,代码行数:56,代码来源:SearchManager.php

示例12: build

 /**
  * @param string $class
  * @param mixed  $fit
  * @return \Doctrine\ORM\QueryBuilder
  */
 public function build($class, $fit = null)
 {
     $alias = uniqid("A");
     /** @var \Doctrine\Orm\QueryBuilder $qb */
     $qb = $this->em->createQueryBuilder();
     if ($fit instanceof SelectFitInterface && $fit->getSelect($alias)) {
         $qb->select($fit->getSelect($alias));
     } else {
         $qb->select($alias);
     }
     $qb->from($class, $alias);
     if ($fit instanceof WhereWithJoinFitInterface) {
         $join = $fit->getJoin($alias);
         if ($join) {
             $qb->join($alias, $join->getJoin(), $join->getAlias(), $join->getCondition());
         }
         $where = $fit->getWhere($alias);
         if ($where) {
             $qb->andWhere($where);
         }
     }
     if ($fit instanceof WhereFitInterface) {
         $where = $fit->getWhere($alias);
         if ($where) {
             $qb->andWhere($where);
             $qb->setParameters($fit->getParameters());
         }
     }
     if ($fit instanceof OrderFitInterface) {
         $order = $fit->getOrder($alias);
         if ($order) {
             $qb->orderBy($order);
         }
     }
     if ($fit instanceof LimitFitInterface) {
         $limit = $fit->getLimit();
         if ($limit) {
             $qb->setMaxResults($limit);
         }
     }
     return $qb;
 }
开发者ID:yosmanyga,项目名称:dql-fit,代码行数:47,代码来源:Builder.php

示例13: finishBatch

 /**
  * @param array  $selectedIds
  * @param string $value
  *
  * @return int
  */
 protected function finishBatch(array &$selectedIds, $value)
 {
     $qBuilder = $this->entityManager->createQueryBuilder();
     $entitiesCount = $qBuilder->update($this->entityName, 'e')->set('e.' . $this->fieldName, ':value')->where($qBuilder->expr()->in('e.' . $this->identifierName, $selectedIds))->getQuery()->setParameter('value', $value)->execute();
     $this->entityManager->flush();
     if ($this->entityManager->getConnection()->getTransactionNestingLevel() == 1) {
         $this->entityManager->clear();
     }
     $selectedIds = [];
     return $entitiesCount;
 }
开发者ID:trustify,项目名称:oroplatform-mass-update-bundle,代码行数:17,代码来源:ActionRepository.php

示例14: getMaxDateFromEntityByUserId

 /**
  * @param string $entityName
  * @param int $userId
  *
  * @return \DateTime|null
  */
 protected function getMaxDateFromEntityByUserId($entityName, $userId)
 {
     $max = null;
     $query = $this->entityManager->createQueryBuilder();
     $query->select('MAX(e.date) AS max_date')->from($entityName, 'e')->where('e.user = :user_id')->setParameter('user_id', $userId)->setMaxResults(1);
     $result = $query->getQuery()->getResult();
     if ($result && isset($result[0]['max_date'])) {
         $max = DateUtil::dateTimeFromMySqlFormat($result[0]['max_date']);
     }
     return $max;
 }
开发者ID:kratenko,项目名称:oc-server3,代码行数:17,代码来源:FieldNoteService.php

示例15: findBySearch

 /**
  * {@inheritdoc}
  *
  * @return FamilyInterface[]
  */
 public function findBySearch($search = null, array $options = [])
 {
     $qb = $this->entityManager->createQueryBuilder()->select('f')->from($this->entityName, 'f');
     $qb->leftJoin('f.translations', 'ft');
     if (null !== $search && '' !== $search) {
         $qb->where('f.code like :search')->setParameter('search', "%{$search}%");
         $qb->orWhere('ft.label like :search')->setParameter('search', "%{$search}%");
     }
     if (isset($options['identifiers']) && is_array($options['identifiers']) && !empty($options['identifiers'])) {
         $qb->andWhere('f.code in (:codes)');
         $qb->setParameter('codes', $options['identifiers']);
     }
     if (isset($options['limit'])) {
         $qb->setMaxResults((int) $options['limit']);
         if (isset($options['page'])) {
             $qb->setFirstResult((int) $options['limit'] * ((int) $options['page'] - 1));
         }
     }
     return $qb->getQuery()->getResult();
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:25,代码来源:FamilySearchableRepository.php


注:本文中的Doctrine\ORM\EntityManagerInterface::createQueryBuilder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。