function Connection::getConditionFieldSuffix
Same name and namespace in other branches
- 11.x core/lib/Drupal/Core/Database/Connection.php \Drupal\Core\Database\Connection::getConditionFieldSuffix()
Gets the field suffix for the specified condition operator.
Only needed when a condition is built as an SQL snippet, for example with where(). Conditions added with condition() get the suffix added when the condition is compiled.
For example, on PostgreSQL the LIKE operator needs a '::text' type-cast on the field:
$suffix = $connection->getConditionFieldSuffix('LIKE');
$query->where("[title]{$suffix} LIKE :pattern", [
':pattern' => '%foo%',
]);
Parameters
string $operator: The condition operator, such as "LIKE", "REGEXP", etc. Case-sensitive.
Return value
string The SQL the database driver needs appended to the field for this operator, for example a type-cast, or an empty string.
File
-
core/
lib/ Drupal/ Core/ Database/ Connection.php, line 1304
Class
- Connection
- Base Database API class.
Namespace
Drupal\Core\DatabaseCode
public function getConditionFieldSuffix(string $operator) : string {
$mapping = $this->mapConditionOperator($operator);
return $mapping['field_suffix'] ?? '';
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.