Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Database/SqlPreprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SqlPreprocessor
use Nette\SmartObject;

/** @var array */
private const MODE_LIST = ['and', 'or', 'set', 'values', 'order'];
private const MODE_LIST = ['and', 'or', 'set', 'values', 'order', 'as'];

private const ARRAY_MODES = [
'INSERT' => 'values',
Expand Down Expand Up @@ -253,6 +253,12 @@ private function formatValue($value, string $mode = null): string
}
return implode(', ', $vx);

} elseif ($mode === 'as') {
foreach ($value as $k => $v) {
$vx[] = $this->delimite($k) . ' AS ' . $v;
}
return implode(', ', $vx);

} else {
throw new Nette\InvalidArgumentException("Unknown placeholder ?$mode.");
}
Expand Down