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

where() public method

Replaces any previously specified restrictions, if any. $qb = $conn->createQueryBuilder() ->select('u.name') ->from('users', 'u') ->where('u.id = ?'); You can optionally programatically build and/or expressions $qb = $conn->createQueryBuilder(); $or = $qb->expr()->orx(); $or->add($qb->expr()->eq('u.id', 1)); $or->add($qb->expr()->eq('u.id', 2)); $qb->update('users', 'u') ->set('u.password', md5('password')) ->where($or);
public where ( mixed $predicates )
$predicates mixed The restriction predicates.
    public function where($predicates)
    {
        if (!(func_num_args() == 1 && $predicates instanceof CompositeExpression)) {
            $predicates = new CompositeExpression(CompositeExpression::TYPE_AND, func_get_args());
        }
        return $this->add('where', $predicates);
    }

Usage Example

Esempio n. 1
0
 public function finalizeQuery(\Doctrine\DBAL\Query\QueryBuilder $query)
 {
     $paramcount = 0;
     if (isset($this->gID) && $this->gID > 0) {
         $query->where('gID = ?')->setParameter($paramcount++, $this->gID);
     }
     switch ($this->sortBy) {
         case "alpha":
             $query->orderBy('pName', 'ASC');
             break;
         case "date":
             $query->orderBy('pDateAdded', 'DESC');
             break;
     }
     switch ($this->featured) {
         case "featured":
             $query->andWhere("pFeatured = 1");
             break;
         case "nonfeatured":
             $query->andWhere("pFeatured = 0");
             break;
     }
     if ($this->activeOnly) {
         $query->andWhere("pActive = 1");
     }
     if ($this->search) {
         $query->andWhere('pName like ?')->setParameter($paramcount++, '%' . $this->search . '%');
     }
     return $query;
 }
All Usage Examples Of Doctrine\DBAL\Query\QueryBuilder::where