Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Doctrine\DBAL\Driver\OCI8;
4
 
5
use Doctrine\DBAL\SQL\Parser\Visitor;
6
 
7
use function count;
8
use function implode;
9
 
10
/**
11
 * Converts positional (?) into named placeholders (:param<num>).
12
 *
13
 * Oracle does not support positional parameters, hence this method converts all
14
 * positional parameters into artificially named parameters.
15
 *
16
 * @internal This class is not covered by the backward compatibility promise
17
 */
18
final class ConvertPositionalToNamedPlaceholders implements Visitor
19
{
20
    /** @var list<string> */
21
    private array $buffer = [];
22
 
23
    /** @var array<int,string> */
24
    private array $parameterMap = [];
25
 
26
    public function acceptOther(string $sql): void
27
    {
28
        $this->buffer[] = $sql;
29
    }
30
 
31
    public function acceptPositionalParameter(string $sql): void
32
    {
33
        $position = count($this->parameterMap) + 1;
34
        $param    = ':param' . $position;
35
 
36
        $this->parameterMap[$position] = $param;
37
 
38
        $this->buffer[] = $param;
39
    }
40
 
41
    public function acceptNamedParameter(string $sql): void
42
    {
43
        $this->buffer[] = $sql;
44
    }
45
 
46
    public function getSQL(): string
47
    {
48
        return implode('', $this->buffer);
49
    }
50
 
51
    /** @return array<int,string> */
52
    public function getParameterMap(): array
53
    {
54
        return $this->parameterMap;
55
    }
56
}