ConditionInterface
interface ConditionInterface (View source)
Interface for a conditional clause in a query.
Methods
Helper function: builds the most common conditional clauses.
Adds an arbitrary WHERE clause to the query.
Sets a condition that is always false.
Gets the, possibly nested, list of conditions in this conditional clause.
Gets a complete list of all values to insert into the prepared statement.
Compiles the saved conditions for later retrieval.
Check whether a condition has been previously compiled.
Creates an object holding a group of conditions.
Creates a new group of conditions ANDed together.
Creates a new group of conditions ORed together.
Details
$this
condition(string|ConditionInterface $field, string|array|SelectInterface|null $value = NULL, string|null $operator = '=')
Helper function: builds the most common conditional clauses.
This method takes 1 to 3 parameters.
If called with 1 parameter, it should be a ConditionInterface that in itself forms a valid where clause. Use e.g. to build clauses with nested ANDs and ORs.
If called with 2 parameters, they are taken as $field and $value with $operator having a value of =.
Do not use this method to test for NULL values. Instead, use QueryConditionInterface::isNull() or QueryConditionInterface::isNotNull().
To improve readability, the operators EXISTS and NOT EXISTS have their own utility method defined.
Drupal considers LIKE case insensitive and the following is often used to tell the database that case insensitive equivalence is desired:
$this
where(string $snippet, array $args = [])
Adds an arbitrary WHERE clause to the query.
$this
isNull(string|SelectInterface $field)
Sets a condition that the specified field be NULL.
$this
isNotNull(string|SelectInterface $field)
Sets a condition that the specified field be NOT NULL.
$this
exists(SelectInterface $select)
Sets a condition that the specified subquery returns values.
$this
notExists(SelectInterface $select)
Sets a condition that the specified subquery returns no values.
$this
alwaysFalse()
Sets a condition that is always false.
array
conditions()
Gets the, possibly nested, list of conditions in this conditional clause.
This method returns by reference. That allows alter hooks to access the data structure directly and manipulate it before it gets compiled.
The data structure that is returned is an indexed array of entries, where each entry looks like the following:
An
arguments()
Gets a complete list of all values to insert into the prepared statement.
compile(Connection $connection, PlaceholderInterface $queryPlaceholder)
Compiles the saved conditions for later retrieval.
This method does not return anything, but simply prepares data to be retrieved via __toString() and arguments().
true
compiled()
Check whether a condition has been previously compiled.
ConditionInterface
conditionGroupFactory($conjunction = 'AND')
Creates an object holding a group of conditions.
See andConditionGroup() and orConditionGroup() for more.
ConditionInterface
andConditionGroup()
Creates a new group of conditions ANDed together.
ConditionInterface
orConditionGroup()
Creates a new group of conditions ORed together.