function views_plugin_query_default::add_where_expression
Add a complex WHERE clause to the query.
The caller is responsible for ensuring that all fields are fully qualified (TABLE.FIELD) and that the table already exists in the query. Internally the dbtng method "where" is used.
Parameters
string $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.
string $snippet: The snippet to check. This can be either a column or a complex expression like "UPPER(table.field) = 'value'".
array $args: An associative array of arguments.
See also
QueryConditionInterface::where()
File
-
plugins/
views_plugin_query_default.inc, line 938
Class
- views_plugin_query_default
- Object used to create a SELECT query.
Code
public function add_where_expression($group, $snippet, $args = array()) {
// 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->set_where_group('AND', $group);
}
$this->where[$group]['conditions'][] = array(
'field' => $snippet,
'value' => $args,
'operator' => 'formula',
);
}