orWhere() public method

$qb = $em->createQueryBuilder() ->select('u.name') ->from('users', 'u') ->where('u.id = 1') ->orWhere('u.id = 2');
See also: where()
public orWhere ( mixed $where )
$where mixed The WHERE statement.
Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function restrict($expression, $condition = DataSourceInterface::CONDITION_AND)
 {
     switch ($condition) {
         case DataSourceInterface::CONDITION_AND:
             $this->queryBuilder->andWhere($expression);
             break;
         case DataSourceInterface::CONDITION_OR:
             $this->queryBuilder->orWhere($expression);
             break;
     }
 }
 public function where($column, $operator = null, $value = null, $boolean = 'and')
 {
     $args = func_get_args();
     if (count($args) == 1) {
         parent::where($args[0]);
         return $this;
     }
     $column = $args[0];
     $boolean = 'and';
     $operator = '=';
     if (count($args) == 2) {
         $value = $args[1];
     }
     if (count($args) == 3) {
         $operator = $args[1];
         $value = $args[2];
     }
     if (count($args) == 4) {
         $operator = $args[1];
         $value = $args[2];
         $boolean = $args[3];
     }
     if (is_array($value)) {
         $operator = $operator == '=' ? 'in' : 'notIn';
         $where_clause = $this->expr()->{$operator}($column, parent::createNamedParameter($value, \Doctrine\DBAL\Connection::PARAM_STR_ARRAY));
     } else {
         $where_clause = $column . $operator . parent::createNamedParameter($value);
     }
     if ($boolean == 'and') {
         parent::andWhere($where_clause);
     } elseif ($boolean == 'or') {
         parent::orWhere($where_clause);
     }
     return $this;
 }
Beispiel #3
0
 /**
  * @param $tableName
  * @param $conditions
  *
  * @return array
  *
  * @throws LookupError
  *
  * @since 1.1.0
  *
  * @author Eddilbert Macharia (http://eddmash.com) <*****@*****.**>
  */
 public static function filters(QueryBuilder $queryBuilder, $conditions)
 {
     // default lookup is equal
     $lookup = 'eq';
     // we add the or conditions afterwards to avoid them being mistaken for "and" conditions when they come first
     $or_combine = [];
     $and_combine = [];
     // create where clause from the conditions given
     foreach ($conditions as $condition) {
         foreach ($condition as $key => $value) {
             $column = self::getLookupColumn($key);
             $lookup = self::getLookUP($key);
             $value = self::prepareValue($value, $lookup);
             echo self::$lookuOptions[$lookup] . '<br>';
             echo $queryBuilder->createNamedParameter($value) . '<br>';
             echo $value . '<br>';
             $lookupCondition = sprintf(self::$lookuOptions[$lookup], $queryBuilder->createNamedParameter($value));
             $queryString = sprintf('%s %s', $column, $lookupCondition);
             if (self::combine($key) === self::$or) {
                 $queryBuilder->orWhere($queryString);
             } else {
                 $queryBuilder->andWhere($queryString);
             }
         }
     }
 }
Beispiel #4
0
 protected function processWhereCondition(array $condition, QBuilder $qbuilder)
 {
     $query = $condition['condition'];
     if (stripos($query, '?') === false) {
         $query .= " = ?";
     }
     $type = isset($condition['type']) ? strtoupper($condition['type']) : 'AND';
     if ($type == 'AND') {
         $qbuilder->andWhere($query);
     } else {
         $qbuilder->orWhere($query);
     }
     if (isset($condition['value'])) {
         $this->params[] = $condition['value'];
     }
 }
 /**
  * @test
  */
 public function orWhereDelegatesToConcreteQueryBuilder()
 {
     $this->concreteQueryBuilder->orWhere('uid=1', 'type=9')->shouldBeCalled()->willReturn($this->subject);
     $this->subject->orWhere('uid=1', 'type=9');
 }
Beispiel #6
0
 /**
  * @param array $conditions
  * @return $this
  */
 public function orWhere($conditions)
 {
     $this->queryBuilder->orWhere($this->clause($conditions));
     return $this;
 }
Beispiel #7
0
 /**
  * Adds one or more restrictions to the query results, forming a logical
  * disjunction with any previously specified restrictions.
  *
  * @param mixed,... $where The WHERE statement.
  *
  * @return QueryBuilder This QueryBuilder instance.
  *
  * @see where()
  */
 public function orWhere(...$where) : QueryBuilder
 {
     $this->concreteQueryBuilder->orWhere(...$where);
     return $this;
 }
Beispiel #8
0
 /**
  * Adds one or more restrictions to the query results, forming a logical
  * disjunction with any previously specified restrictions.
  *
  * @param mixed $where The WHERE statement.
  *
  * @return self
  *
  * @see where()
  */
 public function orWhere($where)
 {
     $this->qb->orWhere($where);
     return $this;
 }