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


PHP Criteria::andWhere方法代码示例

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


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

示例1: getMenu

 public function getMenu()
 {
     $criteria = new Criteria();
     $criteria->orderBy(['hierarchy' => 'asc']);
     $criteria->andWhere($criteria->expr()->eq('parent', null));
     return $this->adminMenuRepository->matching($criteria);
 }
开发者ID:Sywooch,项目名称:WellCommerce,代码行数:7,代码来源:AdminMenuProvider.php

示例2: addFilters

 /**
  * Adds filters to a query builder
  *
  * @param QueryBuilder   $qb
  * @param array|Criteria $filters Additional filtering criteria, e.g. ['allDay' => true, ...]
  *                                or \Doctrine\Common\Collections\Criteria
  */
 protected function addFilters(QueryBuilder $qb, $filters)
 {
     if ($filters) {
         if (is_array($filters)) {
             $newCriteria = new Criteria();
             foreach ($filters as $fieldName => $value) {
                 $newCriteria->andWhere(Criteria::expr()->eq($fieldName, $value));
             }
             $filters = $newCriteria;
         }
         if ($filters instanceof Criteria) {
             $qb->addCriteria($filters);
         }
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:22,代码来源:CalendarEventRepository.php

示例3: searchClients

 public function searchClients(array $criteria, array $orderBy = null, $page = 0, $pageSize = 10)
 {
     $params = new ClientSearch($criteria);
     $criteriaObj = new Criteria();
     if ($params->getApprovedforbusiness()) {
         $criteriaObj->andWhere($criteriaObj->expr()->eq('approvedforbusiness', 1));
     }
     if ($params->getClientcode() != null) {
         $criteriaObj->andWhere($criteriaObj->expr()->contains('clientcode', $params->getClientcode()));
     }
     if ($params->getSearchtext() != null) {
         $criteriaObj->andWhere($criteriaObj->expr()->orX($criteriaObj->expr()->contains('name', $params->getSearchtext()), $criteriaObj->expr()->contains('address', $params->getSearchtext()), $criteriaObj->expr()->contains('postcode', $params->getSearchtext())));
     }
     if ($orderBy != null) {
         $criteriaObj->orderBy($orderBy);
     }
     return $this->clientsRepo->searchByCriteria($criteriaObj, $page, $pageSize);
 }
开发者ID:rmukras,项目名称:coffee,代码行数:18,代码来源:ClientsRepository.php

示例4: initDatabaseMock

 /**
  * Initialize mocks for Doctrine
  * 
  * @param array $managersToMock List of managers to be mocked
  * 
  * @return void
  */
 protected function initDatabaseMock($managersToMock)
 {
     if (is_null($this->mockedManager)) {
         $test = $this;
         foreach ($managersToMock as $manager) {
             $entityName = $manager['entityName'];
             // EntityManager mock
             $entityManagerMock = new \mock\Doctrine\ORM\EntityManager();
             // ClassMetadata mock
             $classMetadata = new \mock\Doctrine\ORM\Mapping\ClassMetadata($entityName);
             $entityClassName = $manager['entityClassName'];
             $this->calling($classMetadata)->getName = function () use($entityClassName) {
                 return $entityClassName;
             };
             // EntityRepository mock
             $entityRepositoryMock = new \mock\Doctrine\ORM\EntityRepository($entityManagerMock, $classMetadata);
             $this->calling($entityRepositoryMock)->find = function ($id) use($test, $entityName) {
                 if (!empty($test->database[$entityName]) && array_key_exists($id, $test->database[$entityName])) {
                     return clone $test->database[$entityName][$id];
                 }
                 return null;
             };
             $this->calling($entityRepositoryMock)->findBy = function ($criteria = [], $sort = null, $limit = null, $start = 0) use($test, $entityName) {
                 $entities = new ArrayCollection($test->database[$entityName]);
                 $crit = new Criteria();
                 foreach ($criteria as $field => $value) {
                     $crit->andWhere($crit->expr()->eq($field, $value));
                 }
                 if (!is_null($sort)) {
                     $crit->orderBy($sort);
                 }
                 $crit->setFirstResult($start);
                 $crit->setMaxResults($limit);
                 return $entities->matching($crit)->map(function ($item) {
                     return clone $item;
                 });
             };
             // Overload main EntityManager functions
             $this->calling($entityManagerMock)->getRepository = function () use($entityRepositoryMock) {
                 return $entityRepositoryMock;
             };
             $this->calling($entityManagerMock)->getClassMetadata = function ($entity) use($classMetadata) {
                 return $classMetadata;
             };
             $this->calling($entityManagerMock)->persist = function ($entity) use($test, $entityName) {
                 if (!$entity->getId()) {
                     if (!empty($test->database[$entityName])) {
                         $entity->setId(count($test->database[$entityName]) + 1);
                     } else {
                         $entity->setId(1);
                     }
                 }
                 $test->database[$entityName][$entity->getId()] = $entity;
                 return true;
             };
             $this->calling($entityManagerMock)->remove = function ($entity) use($test, $entityName) {
                 if (!$entity->getId() || empty($test->database[$entityName][$entity->getId()])) {
                     return false;
                 }
                 unset($test->database[$entityName][$entity->getId()]);
                 return true;
             };
             $mockClass = '\\mock' . $manager['className'];
             $managerMock = new $mockClass($entityManagerMock, $entityName);
             $this->mockedManager[$manager['serviceName']] = $managerMock;
         }
     }
 }
开发者ID:e-ReColNat,项目名称:recolnat-diff,代码行数:75,代码来源:AbstractDoctrineMockedTest.php

示例5: getList

 /**
  * @param int $limit
  * @param int $lastId
  *
  * @return Collection|Car[]
  */
 public function getList($limit, $lastId)
 {
     $criteria = new Criteria();
     $criteria->andWhere($criteria->expr()->gt('id', $lastId));
     return $this->repository->matching($criteria)->slice(0, $limit);
 }
开发者ID:ibrows,项目名称:rest-bundle,代码行数:12,代码来源:CategoryHandler.php

示例6: createFindForGameByTypeAndPlayerCriteria

 /**
  * @param Game $game
  * @param string $eventType
  * @param int $player 1|2
  * @return Criteria
  */
 private function createFindForGameByTypeAndPlayerCriteria(Game $game, $eventType = null, $player = null)
 {
     $criteria = new Criteria();
     $expr = Criteria::expr();
     $criteria->where($expr->eq('game', $game));
     if ($eventType !== null) {
         $criteria->andWhere($expr->eq('type', $eventType));
     }
     if ($player !== null) {
         $criteria->andWhere($expr->eq('player', $player));
     }
     return $criteria;
 }
开发者ID:jlekowski,项目名称:battleships-api,代码行数:19,代码来源:EventRepository.php

示例7: apply

 /**
  * {@inheritdoc}
  */
 public function apply(Criteria $criteria, FilterValue $value = null)
 {
     $expr = $this->createExpression($value);
     if (null !== $expr) {
         $criteria->andWhere($expr);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:10,代码来源:ComparisonFilter.php

示例8: applyFilterSelect

 /**
  * Filter by select value
  * @param  Filter\FilterSelect $filter
  * @return void
  */
 public function applyFilterSelect(Filter\FilterSelect $filter)
 {
     foreach ($filter->getCondition() as $column => $value) {
         $expr = Criteria::expr()->eq($column, $value);
         $this->criteria->andWhere($expr);
     }
 }
开发者ID:ublaboo,项目名称:datagrid,代码行数:12,代码来源:DoctrineCollectionDataSource.php

示例9: getProductReviews

 public function getProductReviews(ProductInterface $product) : Collection
 {
     $criteria = new Criteria();
     $criteria->where($criteria->expr()->eq('product', $product));
     $criteria->andWhere($criteria->expr()->eq('enabled', true));
     return $this->matching($criteria);
 }
开发者ID:WellCommerce,项目名称:ReviewBundle,代码行数:7,代码来源:ReviewRepository.php

示例10: getCriteria

 /**
  * Returns the report's criteria
  *
  * @param ReportConfiguration $configuration
  *
  * @return Criteria
  */
 protected function getCriteria(ReportConfiguration $configuration)
 {
     $criteria = new Criteria();
     $criteria->where($criteria->expr()->gte('createdAt', $configuration->getStartDate()));
     $criteria->andWhere($criteria->expr()->lte('createdAt', $configuration->getEndDate()));
     return $criteria;
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:14,代码来源:ClientReportProvider.php

示例11: findByTag

 public function findByTag($tagstring)
 {
     $criteria = new Criteria();
     $criteria->andWhere(Criteria::expr()->contains('t.name', "%" . $tagstring . "%"));
     $queryBuilder = $this->_em->createQueryBuilder()->select('p')->distinct(true)->from($this->getEntityName(), "p")->leftJoin('Product\\Entity\\ProductTags', 'pt', \Doctrine\ORM\Query\Expr\Join::WITH, 'p.id = pt.idProduct')->leftJoin('Product\\Entity\\Tags', 't', \Doctrine\ORM\Query\Expr\Join::WITH, 't.id = pt.idTag')->addCriteria($criteria)->orderBy("p.creationdate", "ASC")->getQuery();
     return $queryBuilder->getArrayResult();
 }
开发者ID:89snake89,项目名称:PHPTest,代码行数:7,代码来源:ProductRepository.php

示例12: findPreviousOrdersToday

 private function findPreviousOrdersToday() : Collection
 {
     $today = Carbon::now()->startOfDay();
     $criteria = new Criteria();
     $criteria->where($criteria->expr()->gte('updatedAt', $today));
     $criteria->andWhere($criteria->expr()->eq('confirmed', true));
     return $this->orderRepository->matching($criteria);
 }
开发者ID:wellcommerce,项目名称:wellcommerce,代码行数:8,代码来源:OrderNumberGenerator.php

示例13: findByStatusAndBeforeUpdatedAt

 /**
  * Finds operations
  *
  * @param Status $status status to filter upon
  * @param DateTime $date optional date to filter upon
  *
  * @return OperationInterface[]
  */
 public function findByStatusAndBeforeUpdatedAt(Status $status, DateTime $date)
 {
     $criteria = new Criteria();
     $exprBuilder = new ExpressionBuilder();
     $criteria->where($exprBuilder->eq('status', $status->getValue()));
     $criteria->andWhere($exprBuilder->lte('updatedAt', $date));
     return $this->matching($criteria)->toArray();
 }
开发者ID:hipay,项目名称:hipay-wallet-cashout-mirakl-integration,代码行数:16,代码来源:OperationRepository.php

示例14: applyAclToCriteria

 /**
  * Add ACL checks to Criteria
  *
  * @param string   $className
  * @param Criteria $criteria
  * @param string   $permission
  *
  * @return Criteria
  */
 public function applyAclToCriteria($className, Criteria $criteria, $permission)
 {
     $conditionData = $this->builder->getAclConditionData($className, $permission);
     if (!empty($conditionData)) {
         $entityField = $value = $pathExpressionType = $organizationField = $organizationValue = $ignoreOwner = null;
         list($entityField, $value, $pathExpressionType, $organizationField, $organizationValue, $ignoreOwner) = $conditionData;
         if (!is_null($organizationField) && !is_null($organizationValue)) {
             $criteria->andWhere(Criteria::expr()->in($organizationField, [$organizationValue]));
         }
         if (!$ignoreOwner && !empty($value)) {
             if (!is_array($value)) {
                 $value = [$value];
             }
             $criteria->andWhere(Criteria::expr()->in($entityField, $value));
         }
     }
     return $criteria;
 }
开发者ID:nmallare,项目名称:platform,代码行数:27,代码来源:AclHelper.php

示例15: testAndWhere

 public function testAndWhere()
 {
     $expr = new Comparison("field", "=", "value");
     $criteria = new Criteria();
     $criteria->where($expr);
     $expr = $criteria->getWhereExpression();
     $criteria->andWhere($expr);
     $where = $criteria->getWhereExpression();
     $this->assertInstanceOf('Doctrine\\Common\\Collections\\Expr\\CompositeExpression', $where);
     $this->assertEquals(CompositeExpression::TYPE_AND, $where->getType());
     $this->assertSame(array($expr, $expr), $where->getExpressionList());
 }
开发者ID:Dren-x,项目名称:mobit,代码行数:12,代码来源:CriteriaTest.php


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