當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Criteria::orWhere方法代碼示例

本文整理匯總了PHP中Doctrine\Common\Collections\Criteria::orWhere方法的典型用法代碼示例。如果您正苦於以下問題:PHP Criteria::orWhere方法的具體用法?PHP Criteria::orWhere怎麽用?PHP Criteria::orWhere使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\Common\Collections\Criteria的用法示例。


在下文中一共展示了Criteria::orWhere方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: searchByContains

 public function searchByContains(array $criteria, array $orderBy = null, $page = 0, $pageSize = PHP_INT_MAX)
 {
     if ($page < 0 || $pageSize < 1) {
         throw new \Exception("Invalid page or pageSize: page must be >= 0 and pageSize must be > 0");
     } else {
         $criteriaObj = new Criteria();
         $i = 0;
         foreach ($criteria as $field => $value) {
             if ($value == null) {
                 continue;
             } else {
                 if ($i++ == 0) {
                     $criteriaObj->where($criteriaObj->expr()->contains($field, $value));
                 } else {
                     $criteriaObj->orWhere($criteriaObj->expr()->contains($field, $value));
                 }
             }
         }
         if ($orderBy != null) {
             $criteriaObj->orderBy($orderBy);
         }
         $total = $this->repository->matching($criteriaObj)->count();
         $query = $this->repository->createQueryBuilder("q")->addCriteria($criteriaObj);
         $items = $query->setFirstResult($page * $pageSize)->setMaxResults($pageSize)->getQuery()->getResult();
         return ResponseUtils::createSearchResponse($total, $items, $page, $pageSize);
     }
 }
開發者ID:rmukras,項目名稱:coffee,代碼行數:27,代碼來源:Repository.php

示例2: resolve

 public function resolve(int $currentShopId, string $url) : ShopInterface
 {
     $criteria = new Criteria();
     $criteria->where($criteria->expr()->eq('id', $currentShopId));
     $criteria->orWhere($criteria->expr()->eq('url', $url));
     $criteria->orWhere($criteria->expr()->gte('id', 1));
     return $this->matching($criteria)->first();
 }
開發者ID:wellcommerce,項目名稱:wellcommerce,代碼行數:8,代碼來源:ShopRepository.php

示例3: testOrWhere

 public function testOrWhere()
 {
     $expr = new Comparison("field", "=", "value");
     $criteria = new Criteria();
     $criteria->where($expr);
     $expr = $criteria->getWhereExpression();
     $criteria->orWhere($expr);
     $where = $criteria->getWhereExpression();
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\Expr\\CompositeExpression', $where);
     $this->assertEquals(CompositeExpression::TYPE_OR, $where->getType());
     $this->assertSame(array($expr, $expr), $where->getExpressionList());
 }
開發者ID:Dren-x,項目名稱:mobit,代碼行數:12,代碼來源:CriteriaTest.php

示例4: loadUserByUsername

 public function loadUserByUsername($username)
 {
     $criteria = new Criteria();
     $criteria->where(new Comparison("username", Comparison::EQ, $username));
     $criteria->orWhere(new Comparison("email", Comparison::EQ, $username));
     $criteria->setMaxResults(1);
     $user = $this->em->getRepository("CoreUserBundle:User")->matching($criteria)->first();
     if ($user) {
         return $user;
     }
     //throw new UsernameNotFoundException(sprintf('Username "%s" does not exist.', $username));
     throw new BadCredentialsException("Bad credentials.");
 }
開發者ID:pixocode,項目名稱:noostache,代碼行數:13,代碼來源:Provider.php

示例5: addDefaultCriteria

 /**
  * @param Criteria $criteria
  */
 protected function addDefaultCriteria(Criteria $criteria)
 {
     $defaultCriteria = $this->getCriteriaWithOutOrganizationAndUser();
     $criteria->orWhere(Criteria::expr()->orX($defaultCriteria->getWhereExpression()));
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:8,代碼來源:ActivityListAclCriteriaHelper.php

示例6: findAllPublicWithQuery

 public function findAllPublicWithQuery($query, $page, $itemPerPage)
 {
     $publicCriteria = new Criteria();
     $publicCriteria->where($publicCriteria->expr()->eq('r.published', true));
     $queryCriteria = new Criteria();
     $queryCriteria->where($queryCriteria->expr()->contains('r.title', $query));
     $queryCriteria->orWhere($queryCriteria->expr()->contains('r.content', $query));
     $orderCriteria = new Criteria();
     $orderCriteria->orderBy(['r.dateUpdated' => 'DESC']);
     /** @var QueryBuilder $queryBuilder */
     $queryBuilder = $this->objectRepository->createQueryBuilder('r');
     $queryBuilder->addCriteria($publicCriteria);
     $queryBuilder->addCriteria($queryCriteria);
     $queryBuilder->addCriteria($orderCriteria);
     $queryBuilder->setFirstResult(($page - 1) * $itemPerPage);
     $queryBuilder->setMaxResults($itemPerPage);
     return new Paginator($queryBuilder);
 }
開發者ID:Indigo1337,項目名稱:c4d,代碼行數:18,代碼來源:ReadService.php


注:本文中的Doctrine\Common\Collections\Criteria::orWhere方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。