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


PHP Criteria::expr方法代碼示例

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


在下文中一共展示了Criteria::expr方法的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: visualizaAction

 /**
  * view the property selected, if tenant ask for more informations, as him to register
  * @return ViewModel
  */
 public function visualizaAction()
 {
     //save new tenant or get the tenant prior registered
     if ($this->getRequest()->isPost()) {
         //getting posible tenant prior registered
         $criterio = new Criteria();
         $criterio->where($criterio->expr()->eq('nome', $this->getRequest()->getPost('nome')))->andWhere($criterio->expr()->eq('email', $this->getRequest()->getPost('email')))->andWhere($criterio->expr()->eq('foneCelular', $this->getRequest()->getPost('telefone')));
         $locatario = $this->getEm()->getRepository('MyClasses\\Entities\\Locatario')->matching($criterio);
         //if quantity of tenants by criteria above is zero...
         if (!$locatario->count()) {
             //...register new tenant...
             $locatario = new Locatario();
             $locatario->setNome($this->getRequest()->getPost('nome'));
             $locatario->setEmail($this->getRequest()->getPost('email'));
             $locatario->setFoneCelular($this->getRequest()->getPost('telefone'));
             $this->getEm()->persist($locatario);
             $this->getEm()->flush();
             //...else, get the tenant prior registered
         } else {
             $locatario = $locatario->first();
         }
         $this->sessao->locatario = $locatario;
     }
     //get the property and send to view
     if ($this->Params('id')) {
         $imovel = $this->getEm()->getRepository("MyClasses\\Entities\\Imovel")->find($this->Params('id'));
         return new ViewModel(array('imovel' => $imovel, 'mais' => $this->Params('mais'), 'locatario' => $this->sessao->locatario));
     }
 }
開發者ID:Jorgeley,項目名稱:Real-State,代碼行數:33,代碼來源:ImovelController.php

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: indexAction

 /**
  * list the projects
  * @return \Zend\View\Model\ViewModel
  */
 public function indexAction()
 {
     $usuario = $this->getEm()->getRepository('MyClasses\\Entities\\AclUsuario')->findOneBy(array("id" => $this->identity()[0]->getId()));
     if ($this->identity()[1] == "adm") {
         $criterio = new Criteria();
         $criterio->where($criterio->expr()->eq('usuario', $usuario))->orWhere($criterio->expr()->isNull('usuario'));
         $projetos = $this->getEm()->getRepository('MyClasses\\Entities\\Projeto')->matching($criterio);
     } else {
         $projetos = $usuario->getProjetos();
     }
     return new ViewModel(array('projetos' => $projetos));
 }
開發者ID:Jorgeley,項目名稱:Real-State,代碼行數:16,代碼來源:ProjetoController.php

示例8: query

 /**
  * @param DataStructure\Query\Query $queries
  *
  * @return mixed
  */
 public function query(DataStructure\Query\Query $queries)
 {
     $logicFunc = 'andWhere';
     if ($queries instanceof DataStructure\OrQuery) {
         $logicFunc = 'orWhere';
     }
     foreach ($queries as $query) {
         if ($this->isExcludedProperty($query->getProperty())) {
             continue;
         }
         $value = $this->unlockSpecialProperty($query->getProperty(), $query->getValue());
         if ($query instanceof Expression\Equal) {
             $this->criteria->{$logicFunc}(Criteria::expr()->eq($query->getProperty(), $value));
         } elseif ($query instanceof Expression\NotEqual) {
             $this->criteria->{$logicFunc}(Criteria::expr()->neq($query->getProperty(), $value));
         } elseif ($query instanceof Expression\GreaterThan) {
             $this->criteria->{$logicFunc}(Criteria::expr()->gt($query->getProperty(), $value));
         } elseif ($query instanceof Expression\GreaterThanEqual) {
             $this->criteria->{$logicFunc}(Criteria::expr()->gte($query->getProperty(), $value));
         } elseif ($query instanceof Expression\LesserThan) {
             $this->criteria->{$logicFunc}(Criteria::expr()->lt($query->getProperty(), $value));
         } elseif ($query instanceof Expression\LesserThanEqual) {
             $this->criteria->{$logicFunc}(Criteria::expr()->lte($query->getProperty(), $value));
         } elseif ($query instanceof Expression\In) {
             $this->criteria->{$logicFunc}(Criteria::expr()->in($query->getProperty(), $value));
         } elseif ($query instanceof Expression\NotIn) {
             $this->criteria->{$logicFunc}(Criteria::expr()->notIn($query->getProperty(), $query->getValue()));
         }
     }
 }
開發者ID:phprest,項目名稱:phprest-service-request-filter,代碼行數:35,代碼來源:Orm.php

示例9: getGoalsAction

 /**
  * @Rest\View
  * @Rest\Get("/goals")
  */
 public function getGoalsAction(Request $request)
 {
     $user_id = $request->get('user_id');
     if ($user_id == 0) {
         $user = $this->container->get('security.context')->getToken()->getUser();
     } else {
         $user = $this->getDoctrine()->getRepository('AcmeUserBundle:User')->find($user_id);
     }
     if (!$user) {
         throw $this->createNotFoundException('user.not_found');
     }
     /** @var $user User */
     $goals = $user->getGoals()->matching(Criteria::create()->where(Criteria::expr()->eq('isDeleted', 0)));
     if ($user_id != 0 && $user != $this->container->get('security.context')->getToken()->getUser()) {
         $goals = $goals->matching(Criteria::create()->where(Criteria::expr()->eq('isPrivate', 0)));
     }
     $response = [];
     foreach ($goals as $goal) {
         $oneGoal = ['title' => $goal->getName(), 'id' => $goal->getId()];
         $oneGoal['actions'] = [];
         $oneGoal['images'] = [];
         foreach ($goal->getImages() as $image) {
             $oneGoal['images'][] = ['webPath' => $image->getWebPath()];
         }
         foreach ($goal->getActions() as $action) {
             $oneGoal['actions'][] = ['title' => $action->getTitle()];
         }
         $response[] = $oneGoal;
     }
     return $response;
 }
開發者ID:Alex223124,項目名稱:edela,代碼行數:35,代碼來源:GoalController.php

示例10: findAvailableForUser

 /**
  * @param User $user
  * @param int $limit
  * @return Collection|Game[]
  */
 public function findAvailableForUser(User $user, $limit)
 {
     $criteria = new Criteria();
     $expr = Criteria::expr();
     $criteria->where($expr->neq('user1', $user))->andWhere($expr->isNull('user2'))->setMaxResults($limit)->orderBy(['id' => 'DESC']);
     return $this->matching($criteria);
 }
開發者ID:jlekowski,項目名稱:battleships-api,代碼行數:12,代碼來源:GameRepository.php

示例11: subactionComplete

 public function subactionComplete(SubactionProgressEvent $event, $name, EventDispatcher $dispatcher)
 {
     $action = $event->getSubaction()->getAction();
     $user = $event->getUser();
     $userAction = $this->em->getRepository('AcmeEdelaBundle:UserAction')->findOneBy(array('user' => $user, 'action' => $action));
     $userTime = $user->getCurrentDateTime();
     $dayStart = clone $userTime;
     $dayFinish = clone $userTime;
     $dayStart->modify('today midnight');
     $dayFinish->modify('tomorrow midnight');
     $existingProgress = $this->em->getRepository('AcmeEdelaBundle:UserActionProgress')->matching(Criteria::create()->where(Criteria::expr()->eq('userAction', $userAction))->andWhere(Criteria::expr()->gte('createdAt', $dayStart))->andWhere(Criteria::expr()->lte('createdAt', $dayFinish)));
     $dispatch = null;
     if (!$existingProgress->count() && $action->getSubactions()->count() == count($this->em->getRepository('AcmeEdelaBundle:Action')->getSubactions($action->getId(), $user, null, true))) {
         $progress = new UserActionProgress();
         $progress->setUserAction($userAction);
         $progress->setResult(1);
         $this->em->persist($progress);
         $dispatch = true;
     } elseif ($existingProgress->count()) {
         $this->em->remove($existingProgress->first());
         $dispatch = false;
     }
     $this->em->flush();
     if ($dispatch !== null) {
         $event = new ActionEvent($action, $user, $dispatch);
         $dispatcher->dispatch($this->completeEvent, $event);
     }
 }
開發者ID:Alex223124,項目名稱:edela,代碼行數:28,代碼來源:ActionProgressSubscriber.php

示例12: getPaymentsHistoryAction

 /**
  * @Rest\View
  * @Rest\Get("/payment/history")
  */
 public function getPaymentsHistoryAction(Request $request)
 {
     /** @var User $currentUser */
     $currentUser = $this->container->get('security.context')->getToken()->getUser();
     $transactions = $currentUser->getTransactions()->matching(Criteria::create()->where(Criteria::expr()->eq('isProcessed', 1)));
     return $transactions;
 }
開發者ID:Alex223124,項目名稱:edela,代碼行數:11,代碼來源:PaymentController.php

示例13: confirmAction

 /**
  * Confirm email
  *
  * @return \Zend\Http\Response
  */
 public function confirmAction()
 {
     $confirm = $this->params('confirm');
     try {
         if (!$confirm) {
             //$this->getResponse()->setStatusCode(404);
             throw new \Exception('Invalid confirmation code');
         }
         /**
          * @var \Doctrine\ORM\EntityManager $objectManager
          */
         $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager');
         /** @var \User\Entity\User $user */
         $user = $objectManager->getRepository('User\\Entity\\User')->findOneBy(array('confirm' => $confirm));
         if (!$user) {
             throw new \Exception('Invalid confirmation code');
         }
         $user->activate();
         $objectManager->persist($user);
         $objectManager->flush();
         $criteria = Criteria::create()->where(Criteria::expr()->eq('provider', 'equals'));
         $user->getAuths()->matching($criteria)->first()->login($this->getServiceLocator());
         $this->flashMessenger()->addSuccessMessage("You've successfully activated your account");
     } catch (\Exception $exception) {
         $this->flashMessenger()->addErrorMessage($exception->getMessage());
     }
     return $this->redirect()->toRoute('home');
 }
開發者ID:zfury,項目名稱:cmf,代碼行數:33,代碼來源:SignupController.php

示例14: loadWhere

 /**
  * @param array $criteria
  * @param null  $order
  * @param null  $limit
  * @param null  $offset
  *
  * @return static[]
  */
 public static function loadWhere(array $criteria, $order = null, $limit = null, $offset = null)
 {
     $crit = Criteria::create();
     if ($order) {
         $crit->orderBy($order);
     }
     $crit->setMaxResults($limit);
     $crit->setFirstResult($offset);
     foreach ($criteria as $k => $v) {
         if ($v instanceof Criteria) {
             $crit->andWhere($crit->getWhereExpression());
         } elseif ($v instanceof Expression) {
             $crit->andWhere($v);
         } elseif (is_array($v)) {
             $expr = Criteria::expr();
             $crit->andWhere($expr->andX($expr->in($k, $v)));
         } else {
             $expr = Criteria::expr();
             $crit->andWhere($expr->andX($expr->eq($k, $v)));
         }
     }
     $entities = static::getEntityManager()->getRepository(get_called_class())->matching($crit)->toArray();
     foreach ($entities as $entity) {
         /**
          * @var $entity static
          */
         $entity->setExists(true);
         $entity->setPersistedData(call_user_func('get_object_vars', $entity));
     }
     return $entities;
 }
開發者ID:packaged,項目名稱:mappers,代碼行數:39,代碼來源:DoctrineMapper.php

示例15: getOfferingsForTeachingReminders

 /**
  * {@inheritdoc}
  */
 public function getOfferingsForTeachingReminders($daysInAdvance)
 {
     $now = time();
     $startDate = new \DateTime();
     $startDate->setTimezone(new \DateTimeZone('UTC'));
     $startDate->setTimestamp($now);
     $startDate->modify("midnight +{$daysInAdvance} days");
     $daysInAdvance++;
     $endDate = new \DateTime();
     $endDate->setTimezone(new \DateTimeZone('UTC'));
     $endDate->setTimestamp($now);
     $endDate->modify("midnight +{$daysInAdvance} days");
     $criteria = Criteria::create();
     $expr = Criteria::expr();
     $criteria->where($expr->andX($expr->eq('deleted', 0), $expr->gte('startDate', $startDate), $expr->lt('startDate', $endDate)));
     $offerings = $this->getRepository()->matching($criteria);
     // filter out any offerings belonging to unpublished events
     // and with deleted parentage
     $offerings->filter(function (OfferingInterface $offering) {
         $session = $offering->getSession();
         $course = $session->getCourse();
         $publishEvent = $offering->getSession()->getPublishEvent();
         $school = $course->getSchool();
         return isset($publishEvent) && isset($school) && !$session->isDeleted() && !$course->isDeleted();
     });
     return $offerings;
 }
開發者ID:Okami-,項目名稱:ilios,代碼行數:30,代碼來源:OfferingManager.php


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