public function Condition::where in Drupal driver for SQL Server and SQL Azure 8.2
Same name and namespace in other branches
- 3.0.x drivers/lib/Drupal/Driver/Database/sqlsrv/Condition.php \Drupal\Driver\Database\sqlsrv\Condition::where()
Overridden to replace REGEXP expressions. Needs to be tested for complex nested expressions.
Overrides Condition::where
File
- drivers/
lib/ Drupal/ Driver/ Database/ sqlsrv/ Condition.php, line 56
Class
Namespace
Drupal\Driver\Database\sqlsrvCode
public function where($snippet, $args = []) {
$operator = NULL;
if (strpos($snippet, " NOT REGEXP ") !== FALSE) {
$operator = ' NOT REGEXP ';
}
elseif (strpos($snippet, " REGEXP ") !== FALSE) {
$operator = ' REGEXP ';
}
if ($operator !== NULL) {
$fragments = explode($operator, $snippet);
$field = $fragments[0];
$value = $fragments[1];
$comparison = $operator == ' REGEXP ' ? '1' : '0';
$snippet = "REGEXP({$value}, {$field}) = {$comparison}";
$operator = NULL;
}
$this->conditions[] = [
'field' => $snippet,
'value' => $args,
'operator' => $operator,
];
$this->changed = TRUE;
return $this;
}