Doctrine\DBAL\Query\QueryBuilder::orWhere PHP Method

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.
    public function orWhere($where)
    {
        $args = func_get_args();
        $where = $this->getQueryPart('where');
        if ($where instanceof CompositeExpression && $where->getType() === CompositeExpression::TYPE_OR) {
            $where->addMultiple($args);
        } else {
            array_unshift($args, $where);
            $where = new CompositeExpression(CompositeExpression::TYPE_OR, $args);
        }
        return $this->add('where', $where, true);
    }

Usage Example

Esempio n. 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;
     }
 }
All Usage Examples Of Doctrine\DBAL\Query\QueryBuilder::orWhere