private function Connection::quoteIdentifier in Drupal 8
Quotes an identifier if it matches a MySQL reserved keyword.
Parameters
string $identifier: The field to check.
Return value
string The identifier, quoted if it matches a MySQL reserved keyword.
2 calls to Connection::quoteIdentifier()
- Connection::escapeAlias in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Connection.php - Escapes an alias name string.
- Connection::escapeField in core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Connection.php - Escapes a field name string.
File
- core/
lib/ Drupal/ Core/ Database/ Driver/ mysql/ Connection.php, line 497
Class
- Connection
- MySQL implementation of \Drupal\Core\Database\Connection.
Namespace
Drupal\Core\Database\Driver\mysqlCode
private function quoteIdentifier($identifier) {
// Quote identifiers so that MySQL reserved words like 'function' can be
// used as column names. Sometimes the 'table.column_name' format is passed
// in. For example,
// \Drupal\Core\Entity\Sql\SqlContentEntityStorage::buildQuery() adds a
// condition on "base.uid" while loading user entities.
if (strpos($identifier, '.') !== FALSE) {
list($table, $identifier) = explode('.', $identifier, 2);
}
if (in_array(strtolower($identifier), $this->reservedKeyWords, TRUE)) {
// Quote the string for MySQL reserved keywords.
$identifier = '"' . $identifier . '"';
}
return isset($table) ? $table . '.' . $identifier : $identifier;
}