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\PDO\SQLSrv;
4
 
5
use Doctrine\DBAL\Driver\Middleware\AbstractStatementMiddleware;
6
use Doctrine\DBAL\Driver\PDO\Statement as PDOStatement;
7
use Doctrine\DBAL\ParameterType;
8
use Doctrine\Deprecations\Deprecation;
9
use PDO;
10
 
11
use function func_num_args;
12
 
13
final class Statement extends AbstractStatementMiddleware
14
{
15
    private PDOStatement $statement;
16
 
17
    /** @internal The statement can be only instantiated by its driver connection. */
18
    public function __construct(PDOStatement $statement)
19
    {
20
        parent::__construct($statement);
21
 
22
        $this->statement = $statement;
23
    }
24
 
25
    /**
26
     * {@inheritdoc}
27
     *
28
     * @deprecated Use {@see bindValue()} instead.
29
     *
30
     * @param string|int $param
31
     * @param mixed      $variable
32
     * @param int        $type
33
     * @param int|null   $length
34
     * @param mixed      $driverOptions The usage of the argument is deprecated.
35
     */
36
    public function bindParam(
37
        $param,
38
        &$variable,
39
        $type = ParameterType::STRING,
40
        $length = null,
41
        $driverOptions = null
42
    ): bool {
43
        Deprecation::trigger(
44
            'doctrine/dbal',
45
            'https://github.com/doctrine/dbal/pull/5563',
46
            '%s is deprecated. Use bindValue() instead.',
47
            __METHOD__,
48
        );
49
 
50
        if (func_num_args() < 3) {
51
            Deprecation::trigger(
52
                'doctrine/dbal',
53
                'https://github.com/doctrine/dbal/pull/5558',
54
                'Not passing $type to Statement::bindParam() is deprecated.'
55
                    . ' Pass the type corresponding to the parameter being bound.',
56
            );
57
        }
58
 
59
        if (func_num_args() > 4) {
60
            Deprecation::triggerIfCalledFromOutside(
61
                'doctrine/dbal',
62
                'https://github.com/doctrine/dbal/issues/4533',
63
                'The $driverOptions argument of Statement::bindParam() is deprecated.',
64
            );
65
        }
66
 
67
        switch ($type) {
68
            case ParameterType::LARGE_OBJECT:
69
            case ParameterType::BINARY:
70
                $driverOptions ??= PDO::SQLSRV_ENCODING_BINARY;
71
 
72
                break;
73
 
74
            case ParameterType::ASCII:
75
                $type          = ParameterType::STRING;
76
                $length        = 0;
77
                $driverOptions = PDO::SQLSRV_ENCODING_SYSTEM;
78
                break;
79
        }
80
 
81
        return $this->statement->bindParam($param, $variable, $type, $length ?? 0, $driverOptions);
82
    }
83
 
84
    /**
85
     * {@inheritdoc}
86
     */
87
    public function bindValue($param, $value, $type = ParameterType::STRING): bool
88
    {
89
        if (func_num_args() < 3) {
90
            Deprecation::trigger(
91
                'doctrine/dbal',
92
                'https://github.com/doctrine/dbal/pull/5558',
93
                'Not passing $type to Statement::bindValue() is deprecated.'
94
                    . ' Pass the type corresponding to the parameter being bound.',
95
            );
96
        }
97
 
98
        return $this->bindParam($param, $value, $type);
99
    }
100
}