function Schema::skipQuotedRun
Returns the offset past a quoted run of SQL.
Parameters
string $sql: The SQL to scan.
int $offset: Offset to scan from.
Return value
int|null Offset of the first character after the closing quote, or NULL if $offset does not open a quoted run or the run is unterminated.
File
-
core/
modules/ sqlite/ src/ Driver/ Database/ sqlite/ Schema.php, line 749
Class
- Schema
- SQLite implementation of \Drupal\Core\Database\Schema.
Namespace
Drupal\sqlite\Driver\Database\sqliteCode
protected function skipQuotedRun(string $sql, int $offset) : ?int {
$close = match ($sql[$offset] ?? '') { "'" => "'",
'"' => '"',
'`' => '`',
'[' => ']',
default => NULL,
};
if ($close === NULL) {
return NULL;
}
$length = strlen($sql);
for ($i = $offset + 1; $i < $length; $i++) {
if ($sql[$i] !== $close) {
continue;
}
// A doubled quote is an escaped one. Brackets have no escape form.
if ($close !== ']' && ($sql[$i + 1] ?? '') === $close) {
$i++;
continue;
}
return $i + 1;
}
return NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.