public function escapeIdentifier(string $string, bool $quote = true) : string
{
$str = \preg_replace('/[^0-9a-zA-Z_]/', '', $string);
// The first character cannot be [0-9]:
if (\preg_match('/^[0-9]/', $str)) {
throw new DBAlert\InvalidIdentifier(\trk('error.database.invalid_identifier', $string));
}
if ($quote) {
switch ($this->dbengine) {
case 'mssql':
return '[' . $str . ']';
case 'mysql':
return '`' . $str . '`';
default:
return '"' . $str . '"';
}
}
return $str;
}