1 | <?php |
||
10 | class Dbal2Adapter implements AdapterInterface |
||
11 | { |
||
12 | /** |
||
13 | * @var \Doctrine\DBAL\Connection |
||
14 | */ |
||
15 | protected $dbal; |
||
16 | |||
17 | /** |
||
18 | * @var Dbal2Connection |
||
19 | */ |
||
20 | protected $connection; |
||
21 | |||
22 | /** |
||
23 | * Constructor. |
||
24 | * |
||
25 | * @param \Doctrine\DBAL\Connection $dbal |
||
26 | */ |
||
27 | 6 | public function __construct(\Doctrine\DBAL\Connection $dbal) |
|
32 | |||
33 | /** |
||
34 | * {@inheritdoc} |
||
35 | */ |
||
36 | 1 | public function quoteValue($value) |
|
40 | |||
41 | /** |
||
42 | * {@inheritdoc} |
||
43 | */ |
||
44 | 3 | public function query($query, $resultsetType = Resultset::TYPE_ARRAY) |
|
45 | { |
||
46 | // This error may happen with the libmysql instead of mysqlnd and using set statement (set @test=1) |
||
47 | // : "Attempt to read a row while there is no result set associated with the statement" |
||
48 | |||
49 | try { |
||
50 | /** |
||
51 | * @var \Doctrine\DBAL\Driver\Mysqli\MysqliStatement |
||
52 | */ |
||
53 | 3 | $r = $this->dbal->query($query); |
|
54 | |||
55 | 3 | $results = new Resultset($resultsetType); |
|
56 | 3 | if ($r->columnCount() > 0) { |
|
57 | 3 | while ($row = $r->fetch()) { |
|
58 | 2 | $results->append((array) $row); |
|
59 | } |
||
60 | } |
||
61 | 2 | } catch (\Exception $e) { |
|
62 | 2 | $msg = "Doctrine\Dbal2 adapter query error: {$e->getMessage()} [$query]"; |
|
63 | 2 | throw new Exception\InvalidArgumentException($msg); |
|
64 | } |
||
65 | |||
66 | 3 | return $results; |
|
67 | } |
||
68 | |||
69 | /** |
||
70 | * {@inheritdoc} |
||
71 | * |
||
72 | * @return Dbal2Connection |
||
73 | */ |
||
74 | 1 | public function getConnection() |
|
78 | } |
||
79 |