public function LdapQuery::addWhere in Lightweight Directory Access Protocol (LDAP) 8.4
Same name and namespace in other branches
- 8.3 ldap_query/src/Plugin/views/query/LdapQuery.php \Drupal\ldap_query\Plugin\views\query\LdapQuery::addWhere()
Add a simple WHERE clause to the query.
Parameters
mixed $group: The WHERE group to add these to; groups are used to create AND/OR sections. Groups cannot be nested. Use 0 as the default group. If the group does not yet exist it will be created as an AND group.
mixed $field: The name of the field to check.
mixed $value: The value to test the field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
mixed $operator: The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, LIKE BINARY, or BETWEEN. Defaults to =. If $field is a string you have to use 'formula' here.
File
- ldap_query/
src/ Plugin/ views/ query/ LdapQuery.php, line 241
Class
- LdapQuery
- Views query plugin for an SQL query.
Namespace
Drupal\ldap_query\Plugin\views\queryCode
public function addWhere($group, $field, $value = NULL, $operator = NULL) : void {
// Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
// the default group.
if (empty($group)) {
$group = 0;
}
// Check for a group.
if (!isset($this->where[$group])) {
$this
->setWhereGroup('AND', $group);
}
if (!empty($operator) && $operator !== 'LIKE') {
$this->where[$group]['conditions'][] = [
'field' => $field,
'value' => $value,
'operator' => $operator,
];
}
}