Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

Revision 148 Revision 621
Zeile 1... Zeile 1...
1
<?php
1
<?php
Zeile 2... Zeile 2...
2
 
2
 
Zeile 3... Zeile -...
3
namespace Doctrine\DBAL\Driver\PDO;
-
 
4
 
-
 
5
use Doctrine\DBAL\Driver\Exception as ExceptionInterface;
3
namespace Doctrine\DBAL\Driver\PDO;
6
use Doctrine\DBAL\Driver\Exception\UnknownParameterType;
4
 
7
use Doctrine\DBAL\Driver\Result as ResultInterface;
5
use Doctrine\DBAL\Driver\Result as ResultInterface;
8
use Doctrine\DBAL\Driver\Statement as StatementInterface;
6
use Doctrine\DBAL\Driver\Statement as StatementInterface;
9
use Doctrine\DBAL\ParameterType;
-
 
10
use Doctrine\Deprecations\Deprecation;
7
use Doctrine\DBAL\ParameterType;
11
use PDO;
8
use Doctrine\Deprecations\Deprecation;
Zeile 12... Zeile 9...
12
use PDOException;
9
use PDOException;
13
use PDOStatement;
10
use PDOStatement;
14
 
11
 
Zeile 15... Zeile 12...
15
use function array_slice;
12
use function array_slice;
16
use function func_get_args;
13
use function func_get_args;
17
use function func_num_args;
-
 
18
 
-
 
19
final class Statement implements StatementInterface
-
 
20
{
-
 
21
    private const PARAM_TYPE_MAP = [
-
 
22
        ParameterType::NULL => PDO::PARAM_NULL,
-
 
23
        ParameterType::INTEGER => PDO::PARAM_INT,
-
 
24
        ParameterType::STRING => PDO::PARAM_STR,
-
 
25
        ParameterType::ASCII => PDO::PARAM_STR,
-
 
26
        ParameterType::BINARY => PDO::PARAM_LOB,
-
 
27
        ParameterType::LARGE_OBJECT => PDO::PARAM_LOB,
14
use function func_num_args;
Zeile 28... Zeile 15...
28
        ParameterType::BOOLEAN => PDO::PARAM_BOOL,
15
 
29
    ];
16
final class Statement implements StatementInterface
30
 
17
{
Zeile 48... Zeile 35...
48
                'Not passing $type to Statement::bindValue() is deprecated.'
35
                'Not passing $type to Statement::bindValue() is deprecated.'
49
                    . ' Pass the type corresponding to the parameter being bound.',
36
                    . ' Pass the type corresponding to the parameter being bound.',
50
            );
37
            );
51
        }
38
        }
Zeile 52... Zeile 39...
52
 
39
 
Zeile 53... Zeile 40...
53
        $type = $this->convertParamType($type);
40
        $pdoType = ParameterTypeMap::convertParamType($type);
54
 
41
 
55
        try {
42
        try {
56
            return $this->stmt->bindValue($param, $value, $type);
43
            return $this->stmt->bindValue($param, $value, $pdoType);
57
        } catch (PDOException $exception) {
44
        } catch (PDOException $exception) {
58
            throw Exception::new($exception);
45
            throw Exception::new($exception);
Zeile 99... Zeile 86...
99
                'https://github.com/doctrine/dbal/issues/4533',
86
                'https://github.com/doctrine/dbal/issues/4533',
100
                'The $driverOptions argument of Statement::bindParam() is deprecated.',
87
                'The $driverOptions argument of Statement::bindParam() is deprecated.',
101
            );
88
            );
102
        }
89
        }
Zeile 103... Zeile 90...
103
 
90
 
Zeile 104... Zeile 91...
104
        $type = $this->convertParamType($type);
91
        $pdoType = ParameterTypeMap::convertParamType($type);
105
 
92
 
106
        try {
93
        try {
107
            return $this->stmt->bindParam(
94
            return $this->stmt->bindParam(
108
                $param,
95
                $param,
109
                $variable,
96
                $variable,
110
                $type,
97
                $pdoType,
111
                $length ?? 0,
98
                $length ?? 0,
112
                ...array_slice(func_get_args(), 4),
99
                ...array_slice(func_get_args(), 4),
113
            );
100
            );
Zeile 136... Zeile 123...
136
            throw Exception::new($exception);
123
            throw Exception::new($exception);
137
        }
124
        }
Zeile 138... Zeile 125...
138
 
125
 
139
        return new Result($this->stmt);
126
        return new Result($this->stmt);
140
    }
-
 
141
 
-
 
142
    /**
-
 
143
     * Converts DBAL parameter type to PDO parameter type
-
 
144
     *
-
 
145
     * @param int $type Parameter type
-
 
146
     *
-
 
147
     * @throws ExceptionInterface
-
 
148
     */
-
 
149
    private function convertParamType(int $type): int
-
 
150
    {
-
 
151
        if (! isset(self::PARAM_TYPE_MAP[$type])) {
-
 
152
            throw UnknownParameterType::new($type);
-
 
153
        }
-
 
154
 
-
 
155
        return self::PARAM_TYPE_MAP[$type];
-
 
156
    }
127
    }