Statement.php 1.24 KB
Newer Older
1 2 3 4
<?php

namespace Doctrine\DBAL\Portability;

5
use Doctrine\DBAL\Driver\Result as ResultInterface;
6
use Doctrine\DBAL\Driver\Statement as DriverStatement;
7
use Doctrine\DBAL\ParameterType;
8

9
/**
Benjamin Morel's avatar
Benjamin Morel committed
10
 * Portability wrapper for a Statement.
11
 */
12
final class Statement implements DriverStatement
13
{
14
    /** @var DriverStatement */
15
    private $stmt;
16

17 18
    /** @var Converter */
    private $converter;
19 20

    /**
Benjamin Morel's avatar
Benjamin Morel committed
21
     * Wraps <tt>Statement</tt> and applies portability measures.
22
     */
23
    public function __construct(DriverStatement $stmt, Converter $converter)
24
    {
25 26
        $this->stmt      = $stmt;
        $this->converter = $converter;
27 28
    }

Benjamin Morel's avatar
Benjamin Morel committed
29 30 31
    /**
     * {@inheritdoc}
     */
32
    public function bindParam($column, &$variable, $type = ParameterType::STRING, $length = null)
33
    {
34
        return $this->stmt->bindParam($column, $variable, $type, $length);
35
    }
36

Benjamin Morel's avatar
Benjamin Morel committed
37 38 39
    /**
     * {@inheritdoc}
     */
40
    public function bindValue($param, $value, $type = ParameterType::STRING)
41 42 43 44
    {
        return $this->stmt->bindValue($param, $value, $type);
    }

Benjamin Morel's avatar
Benjamin Morel committed
45 46 47
    /**
     * {@inheritdoc}
     */
48
    public function execute($params = null): ResultInterface
49
    {
50 51 52
        return new Result(
            $this->stmt->execute($params),
            $this->converter
53
        );
54
    }
55
}