public function Condition::where in Drupal driver for SQL Server and SQL Azure 4.2.x
Same name and namespace in other branches
- 3.1.x src/Driver/Database/sqlsrv/Condition.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Condition::where()
- 4.0.x src/Driver/Database/sqlsrv/Condition.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Condition::where()
- 4.1.x src/Driver/Database/sqlsrv/Condition.php \Drupal\sqlsrv\Driver\Database\sqlsrv\Condition::where()
Overridden to replace REGEXP expressions. Needs to be tested for complex nested expressions.
Overrides Condition::where
File
- src/
Driver/ Database/ sqlsrv/ Condition.php, line 56
Class
Namespace
Drupal\sqlsrv\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;
}