where() public method

where() accepts an arbitrary number of parameters. Each parameter must contain a logical expression or an array with logical expressions. If you specify multiple logical expression they are connected using a logical and. Multiple calls to where() will join the expressions using a logical and. Example: $q->select( '*' )->from( 'table' )->where( $q->expr->eq( 'id', 1 ) );
public where ( ) : eZ\Publish\Core\Persistence\Database\SelectQuery
return eZ\Publish\Core\Persistence\Database\SelectQuery
Example #1
0
 /**
  * Adds field filters condition to the WHERE clause of the given $query.
  *
  * Conditions are combined with existing ones using logical AND operator.
  *
  * @param \eZ\Publish\Core\Persistence\Database\SelectQuery $query
  * @param array $fieldFilters
  */
 protected function addFieldFiltersConditions(SelectQuery $query, array $fieldFilters)
 {
     $languageMask = $this->getFieldFiltersLanguageMask($fieldFilters);
     // Only apply if languages are defined in $fieldFilters;
     // 'useAlwaysAvailable' does not make sense on its own
     if ($languageMask === null) {
         return;
     }
     // Condition for the language part of $fieldFilters
     $languageMaskExpression = $query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn("language_id", "ezcontentobject_attribute"), $query->bindValue($languageMask, null, \PDO::PARAM_INT)), $query->bindValue(0, null, \PDO::PARAM_INT));
     // If 'useAlwaysAvailable' is set to true, additionally factor in condition for the
     // Content's main language that is marked as always available
     if (!isset($fieldFilters["useAlwaysAvailable"]) || $fieldFilters["useAlwaysAvailable"] === true) {
         $query->where($query->expr->lOr($languageMaskExpression, $query->expr->lAnd($query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn("language_id", "ezcontentobject_attribute"), $this->dbHandler->quoteColumn("initial_language_id", "ezcontentobject")), $query->bindValue(0, null, \PDO::PARAM_INT)), $query->expr->gt($query->expr->bitAnd($this->dbHandler->quoteColumn("language_id", "ezcontentobject_attribute"), $query->bindValue(1, null, \PDO::PARAM_INT)), $query->bindValue(0, null, \PDO::PARAM_INT)))));
     } else {
         // Matching on a given list of languages
         $query->where($languageMaskExpression);
     }
 }