Skip to content

Commit 8b03ebf

Browse files
committed
cs
1 parent dd3fba6 commit 8b03ebf

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

src/Database/SqlPreprocessor.php

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,17 @@ public function process(array $params, bool $useParams = false): array
102102
$prev = $this->counter;
103103
$this->arrayMode = null;
104104
$res[] = Nette\Utils\Strings::replace(
105-
$param,
106-
'~\'[^\']*+\'|"[^"]*+"|\?[a-z]*|^\s*+(?:\(?\s*SELECT|INSERT|UPDATE|DELETE|REPLACE|EXPLAIN)\b|\b(?:SET|WHERE|HAVING|ORDER BY|GROUP BY|KEY UPDATE)(?=\s*$|\s*\?)|\bIN\s+(?:\?|\(\?\))|/\*.*?\*/|--[^\n]*~Dsi',
105+
$param, /** @lang RegExp */
106+
'~
107+
\'[^\']*+\'
108+
|"[^"]*+"
109+
|\?[a-z]*
110+
|^\s*+(?:\(?\s*SELECT|INSERT|UPDATE|DELETE|REPLACE|EXPLAIN)\b
111+
|\b(?:SET|WHERE|HAVING|ORDER\ BY|GROUP\ BY|KEY\ UPDATE)(?=\s*$|\s*\?)
112+
|\bIN\s+(?:\?|\(\?\))
113+
|/\*.*?\*/
114+
|--[^\n]*
115+
~Dsix',
107116
\Closure::fromCallable([$this, 'callback'])
108117
);
109118
} else {
@@ -208,7 +217,10 @@ private function formatValue($value, string $mode = null): string
208217
if ($mode === self::MODE_VALUES) { // (key, key, ...) VALUES (value, value, ...)
209218
if (array_key_exists(0, $value)) { // multi-insert
210219
if (!is_array($value[0]) && !$value[0] instanceof Row) {
211-
throw new Nette\InvalidArgumentException('Automaticaly detected multi-insert, but values aren\'t array. If you need try to change mode like "?[' . implode('|', self::MODES) . ']". Mode "' . $mode . '" was used.');
220+
throw new Nette\InvalidArgumentException(
221+
'Automaticaly detected multi-insert, but values aren\'t array. If you need try to change mode like "?['
222+
. implode('|', self::MODES) . ']". Mode "' . $mode . '" was used.'
223+
);
212224
}
213225
foreach ($value[0] as $k => $v) {
214226
$kx[] = $this->delimite($k);

0 commit comments

Comments
 (0)