예제 #1
0
 protected function applySearch(QueryBuilder $query)
 {
     if (!$this->search) {
         return;
     }
     $query->addOr($query->expr()->field($this->map('title'))->equals($this->matchAny($this->search)))->addOr($query->expr()->field($this->map('body'))->equals($this->matchAny($this->search)))->addOr($query->expr()->field($this->map('teaser'))->equals($this->matchAny($this->search)))->addOr($query->expr()->field($this->map('category'))->equals($this->matchAny($this->search)));
 }
 /**
  * {@inheritdoc}
  */
 public function addFieldFilter($field, $operator, $value)
 {
     $value = is_array($value) ? $value : [$value];
     if ($operator === 'NOT IN') {
         $this->qb->field($field)->notIn($value);
     } else {
         if (in_array('empty', $value)) {
             unset($value[array_search('empty', $value)]);
             $expr = new Expr();
             $expr = $expr->field($field)->exists(false);
             $this->qb->addOr($expr);
         }
         if (count($value) > 0) {
             $expr = new Expr();
             $expr->field($field)->in($value);
             $this->qb->addOr($expr);
         }
     }
     return $this;
 }
예제 #3
0
 /**
  * @param   array $params
  * @param   QueryBuilder $queryBuilder
  * @return  mixed
  */
 public function createQuery($params, $queryBuilder)
 {
     if (isset($params['search']) && !empty($params['search'])) {
         $search = strtolower($params['search']);
         $expr = $queryBuilder->expr()->operator('$text', ['$search' => $search]);
         $queryBuilder->field(null)->equals($expr->getQuery());
     }
     if (isset($params['location']) && isset($params['location']->coordinates)) {
         $coordinates = $params['location']->coordinates->getCoordinates();
         $queryBuilder->field('preferredJob.desiredLocations.coordinates')->geoWithinCenter($coordinates[0], $coordinates[1], (double) $params['d'] / 100);
     }
     $queryBuilder->addOr($queryBuilder->expr()->field('permissions.view')->equals($this->user->getId()))->addOr($queryBuilder->expr()->field('status.name')->equals(Status::PUBLIC_TO_ALL));
     //$q = $queryBuilder->getQuery()->debug();
     return $queryBuilder;
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function orWhere($where)
 {
     $this->queryBuilder->addOr($where);
     return $this;
 }
예제 #5
0
 /**
  * Adds an "or" expression to the current query.
  *
  * You can create the expression using the expr() method:
  *
  *	   $qb = $this->createQueryBuilder('User');
  *	   $qb
  *		  ->addOr($qb->expr()->field('first_name')->equals('Kris'))
  *		  ->addOr($qb->expr()->field('first_name')->equals('Chris'));
  *
  * @param array|QueryBuilder $expression
  * @return QueryProxy this instance
  */
 public function addOr($expression)
 {
     $this->queryChanged = true;
     parent::addOr($expression);
 }