diff options
Diffstat (limited to 'vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php')
| -rw-r--r-- | vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php b/vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php new file mode 100644 index 0000000..5898a2c --- /dev/null +++ b/vendor/doctrine/dbal/src/Driver/OCI8/ConvertPositionalToNamedPlaceholders.php | |||
| @@ -0,0 +1,58 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | declare(strict_types=1); | ||
| 4 | |||
| 5 | namespace Doctrine\DBAL\Driver\OCI8; | ||
| 6 | |||
| 7 | use Doctrine\DBAL\SQL\Parser\Visitor; | ||
| 8 | |||
| 9 | use function count; | ||
| 10 | use function implode; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * Converts positional (?) into named placeholders (:param<num>). | ||
| 14 | * | ||
| 15 | * Oracle does not support positional parameters, hence this method converts all | ||
| 16 | * positional parameters into artificially named parameters. | ||
| 17 | * | ||
| 18 | * @internal This class is not covered by the backward compatibility promise | ||
| 19 | */ | ||
| 20 | final class ConvertPositionalToNamedPlaceholders implements Visitor | ||
| 21 | { | ||
| 22 | /** @var list<string> */ | ||
| 23 | private array $buffer = []; | ||
| 24 | |||
| 25 | /** @var array<int,string> */ | ||
| 26 | private array $parameterMap = []; | ||
| 27 | |||
| 28 | public function acceptOther(string $sql): void | ||
| 29 | { | ||
| 30 | $this->buffer[] = $sql; | ||
| 31 | } | ||
| 32 | |||
| 33 | public function acceptPositionalParameter(string $sql): void | ||
| 34 | { | ||
| 35 | $position = count($this->parameterMap) + 1; | ||
| 36 | $param = ':param' . $position; | ||
| 37 | |||
| 38 | $this->parameterMap[$position] = $param; | ||
| 39 | |||
| 40 | $this->buffer[] = $param; | ||
| 41 | } | ||
| 42 | |||
| 43 | public function acceptNamedParameter(string $sql): void | ||
| 44 | { | ||
| 45 | $this->buffer[] = $sql; | ||
| 46 | } | ||
| 47 | |||
| 48 | public function getSQL(): string | ||
| 49 | { | ||
| 50 | return implode('', $this->buffer); | ||
| 51 | } | ||
| 52 | |||
| 53 | /** @return array<int,string> */ | ||
| 54 | public function getParameterMap(): array | ||
| 55 | { | ||
| 56 | return $this->parameterMap; | ||
| 57 | } | ||
| 58 | } | ||
