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


PHP EntityManager::createQueryBuilder方法代码示例

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


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

示例1: createQueryBuilder

 /**
  * @param string|null
  * @param string|null
  * @param string|null
  * @return QueryBuilder
  */
 public function createQueryBuilder($entityClass = NULL, $alias = NULL, $indexBy = NULL)
 {
     $qb = $this->entityManager->createQueryBuilder();
     if ($entityClass) {
         $qb->from($entityClass, $alias, $indexBy);
         $qb->select($alias);
     }
     return $qb;
 }
开发者ID:librette,项目名称:doctrine-queries,代码行数:15,代码来源:Queryable.php

示例2: delete

 public function delete($value)
 {
     // formating hours on date
     $date = new \DateTime(strtotime(time()));
     $date = $date->modify('-' . $value . 'hours')->format('Y-m-d H:i:s');
     // deleting rows by doctrine with cascade delete entity settings in db schema
     $qb = $this->em->createQueryBuilder();
     $q = $qb->delete(Search::getClassName(), 's')->where($qb->expr()->lt('s.date', '?1'))->setParameter(1, $date)->getQuery();
     return $numberDeleted = $q->getResult();
 }
开发者ID:tkliner,项目名称:etn-github,代码行数:10,代码来源:TimeDelete.php

示例3: getNextPositionByEvent

 /**
  * @param \App\Model\Event\Entity\Event $event
  *
  * @return array
  */
 public function getNextPositionByEvent(Entity\Event $event)
 {
     $query = $this->em->createQueryBuilder()->select('MAX(p.position)')->from(Entity\Performance::class, 'p')->whereCriteria(['p.event' => $event])->getQuery();
     try {
         $result = $query->getResult(AbstractQuery::HYDRATE_SINGLE_SCALAR);
         $nextPosition = $result + 1;
     } catch (NoResultException $e) {
         $nextPosition = 1;
     }
     return $nextPosition;
 }
开发者ID:Kotys,项目名称:eventor.io,代码行数:16,代码来源:Performance.php

示例4: generateAndPersistNewAddresses

 private function generateAndPersistNewAddresses(int $count)
 {
     $qb = $this->entityManager->createQueryBuilder();
     $qb->select('MAX(address.bip32index)')->from(Address::getClassName(), 'address');
     $index = (int) $qb->getQuery()->getSingleScalarResult();
     for ($i = 0; $i < $count; $i++) {
         list($address, $index) = $this->generateNewAddress($index);
         $addressEntity = new Address($address, $index);
         $this->entityManager->persist($addressEntity);
     }
     $this->entityManager->flush();
     file_put_contents($this->newAddressesFile, true);
 }
开发者ID:ParalelniPolis,项目名称:bitcoinJukebox,代码行数:13,代码来源:AddressProvider.php

示例5: getInvitation

 /**
  * @param string $email
  * @param string|null $token
  * @return Invitation|null
  */
 public function getInvitation($email, $token = null)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('i, partial s.{id, username}')->from(Invitation::class, 'i')->leftJoin('i.sender', 's')->where('i.email = :email')->setParameter('email', $email);
     if (isset($token)) {
         $qb->andWhere('i.token = :token')->setParameter('token', $token);
     }
     try {
         $invitation = $qb->getQuery()->getSingleResult();
     } catch (NoResultException $e) {
         $this->onInfo("Email: {$email} NOT found. [getInvitationByEmail]", $e, self::class);
         return null;
     }
     return $invitation;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:20,代码来源:InvitationsReader.php

示例6: createBasicQuery

 private function createBasicQuery(Kdyby\Doctrine\EntityManager $entityManager)
 {
     $qb = $entityManager->createQueryBuilder();
     $qb->from(Comment::class, 'c');
     foreach ($this->filter as $modifier) {
         $modifier($qb);
     }
     return $qb;
 }
开发者ID:blitzik,项目名称:CMS,代码行数:9,代码来源:CommentQuery.php

示例7: getBasicDQL

 /**
  * @param int $listingID
  * @return \Kdyby\Doctrine\QueryBuilder
  */
 private function getBasicDQL($listingID = null)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('li, lo, wh')->from(ListingItem::class, 'li')->innerJoin('li.listing', 'l')->innerJoin('li.locality', 'lo')->innerJoin('li.workedHours', 'wh');
     if (isset($listingID)) {
         $qb->where('li.listing = :listingID')->setParameter('listingID', $listingID);
     }
     return $qb;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:13,代码来源:ListingItemsReader.php

示例8: getEventsByUser

 /**
  * Získá události pro konkrétního uživatele
  * @param \App\Model\Entity\User $user
  * @return type
  */
 function getEventsByUser($userEntity)
 {
     if ($userEntity) {
         /** @var \App\Model\Entity\Client $client */
         $client = $userEntity->getClient();
         $qb = $this->em->createQueryBuilder();
         $qb->from('\\App\\Model\\Entity\\Event', 'e')->join('\\App\\Model\\Entity\\User', 'u')->select('e')->where($qb->expr()->andX($qb->expr()->orX($qb->expr()->isNull('e.deletedAt'), $qb->expr()->gt('e.deletedAt', ':now')), $qb->expr()->eq('e.client', $client->id)))->setParameter('now', new \DateTime('now'));
         return $qb->getQuery()->getResult();
     }
     return array();
 }
开发者ID:MrTommy1979,项目名称:reference,代码行数:16,代码来源:EventService.php

示例9: getPage

 /**
  * @param int $pageID
  * @param bool $withCommentsCount
  * @return Page|null
  */
 public function getPage($pageID, $withCommentsCount = false)
 {
     $pageQB = $this->em->createQueryBuilder();
     $pageQB->select('p, u, l')->from(Page::class, 'p')->join('p.url', 'u')->join('p.locale', 'l')->where('p.id = :pageID')->setParameter('pageID', $pageID);
     if ((bool) $withCommentsCount === true) {
         $pageQB->addSelect('COUNT(c.page) AS commentsCount');
         $pageQB->leftJoin(Comment::class, 'c', Join::WITH, 'c.page = p');
         $pageQB->groupBy('p.id');
     }
     $page = $pageQB->getQuery()->getOneOrNullResult();
     return $page;
 }
开发者ID:blitzik,项目名称:CMS,代码行数:17,代码来源:PageFacade.php

示例10: getUrlEntity

 /**
  * @param $presenter
  * @param $action
  * @param $internal_id
  * @return Url
  */
 private function getUrlEntity($presenter, $action, $internal_id = null)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('u, rt')->from(Url::class, 'u')->leftJoin('u.actualUrlToRedirect', 'rt')->where('u.presenter = :p AND u.action = :a')->setParameters(['p' => $presenter, 'a' => $action]);
     if ($internal_id !== null) {
         $qb->andWhere('u.internalId = :i')->setParameter('i', $internal_id);
     }
     $url = $qb->getQuery()->setMaxResults(1)->getResult();
     if (empty($url)) {
         return null;
     }
     return $url[0];
 }
开发者ID:blitzik,项目名称:CMS,代码行数:19,代码来源:Router.php

示例11: isValueDuplicate

 /**
  * @param  EntityManager    $em
  * @param  string           $entity
  * @param  string           $attribute
  * @param  string           $value
  * @param  string           $locale
  * @return BaseEntity|FALSE if value if not a duplicate
  */
 public function isValueDuplicate(EntityManager $em, $entity, $attribute, $value, $locale = null)
 {
     $qb = $em->createQueryBuilder();
     $qb->select('e')->from($entity, 'e');
     if (empty($locale)) {
         $qb->where('e.' . $attribute . ' = :' . $attribute);
         $qb->setParameter($attribute, $value);
     } else {
         $qb->leftJoin('e.translations', 't');
         $qb->where('t.' . $attribute . ' = :' . $attribute . ' AND t.locale = :locale');
         $qb->setParameters([$attribute => $value, 'locale' => $locale]);
     }
     $result = $qb->getQuery()->getResult();
     return !empty($result) ? $result[0] : false;
 }
开发者ID:CSHH,项目名称:website,代码行数:23,代码来源:DuplicityChecker.php

示例12: getMostReadedArticles

 /**
  * Vraci nejctenejsi clanky
  * @param int $count
  * @param DateTime|NULL $period
  * @return Entities\Article[]
  */
 public function getMostReadedArticles($count = 1, $period = NULL)
 {
     if ($period === NULL) {
         $now = new DateTime();
         $period = $now->modify("-2 month");
     }
     $cacheId = 'read-' . $count;
     $query = $this->em->createQueryBuilder();
     //vyhledavaci podminka
     $whereConditon = $query->expr()->andX();
     $whereConditon->add($query->expr()->gt('a.publishDate', ':period'));
     $whereConditon->add($query->expr()->eq('a.published', 'TRUE'));
     $result = $query->select('a')->from('App\\Model\\Entities\\Article', 'a')->where($whereConditon)->orderBy('a.counter', 'DESC')->setMaxResults($count)->getQuery()->useResultCache(TRUE, 600, $cacheId);
     $result->setParameter('period', $period);
     return $result->getResult();
 }
开发者ID:krupaj,项目名称:my-blog,代码行数:22,代码来源:ArticleRepository.php

示例13: getBasicDQL

 private function getBasicDQL($id)
 {
     $qb = $this->em->createQueryBuilder();
     $qb->select('l')->from(Listing::class, 'l')->where('l.id = :id')->setParameter('id', $id);
     return $qb;
 }
开发者ID:blitzik,项目名称:vycetky-doctrine,代码行数:6,代码来源:ListingsReader.php

示例14: getAllGenreNames

 /**
  * @return string[]
  */
 public function getAllGenreNames() : array
 {
     $qb = $this->entityManager->createQueryBuilder();
     $qb->select('g.name')->from(Genre::getClassName(), 'g');
     return array_column($qb->getQuery()->getScalarResult(), 'name');
 }
开发者ID:ParalelniPolis,项目名称:bitcoinJukebox,代码行数:9,代码来源:GenresManager.php

示例15: findContentEntity

 /**
  * @param $namespace
  * @param $name
  * @param $locale
  * @return DoctrineEntity
  */
 private function findContentEntity($namespace, $name, $locale)
 {
     /** @var DoctrineEntity[] $result */
     return $this->entityManager->createQueryBuilder()->select('c')->from(DoctrineEntity::class, 'c')->where('c.namespace = :namespace')->andWhere('c.name = :name')->andWhere('c.locale = :locale')->setParameters(['namespace' => $namespace, 'name' => $name, 'locale' => $locale])->getQuery()->getOneOrNullResult();
 }
开发者ID:FreezyBee,项目名称:Editrouble,代码行数:11,代码来源:Doctrine.php


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