| 1 | <?php |
||
| 10 | class ZendDb2Adapter implements AdapterInterface |
||
| 11 | { |
||
| 12 | /** |
||
| 13 | * @var \Zend\Db\Adapter\Adapter |
||
| 14 | */ |
||
| 15 | protected $zendAdapter; |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @var ZendDb2Connection |
||
| 19 | */ |
||
| 20 | protected $connection; |
||
| 21 | |||
| 22 | /** |
||
| 23 | * Constructor. |
||
| 24 | * |
||
| 25 | * @param \Zend\Db\Adapter\Adapter $zendAdapter |
||
| 26 | */ |
||
| 27 | 6 | public function __construct(\Zend\Db\Adapter\Adapter $zendAdapter) |
|
| 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 | try { |
||
| 47 | 3 | $r = $this->zendAdapter->query($query)->execute(); |
|
|
|
|||
| 48 | 3 | $results = new Resultset($resultsetType); |
|
| 49 | 3 | if ($r instanceof \Zend\Db\ResultSet\ResultSet) { |
|
| 50 | foreach ($r as $row) { |
||
| 51 | $results->append((array) $row); |
||
| 52 | } |
||
| 53 | 3 | } elseif ($r instanceof \Zend\Db\Adapter\Driver\ResultInterface && $r->getFieldCount() > 0) { |
|
| 54 | 2 | foreach ($r as $row) { |
|
| 55 | 3 | $results->append($row); |
|
| 56 | } |
||
| 57 | } |
||
| 58 | 2 | } catch (\Exception $e) { |
|
| 59 | 2 | $msg = "ZendDb2 adapter query error: {$e->getMessage()} [$query]"; |
|
| 60 | 2 | throw new Exception\InvalidArgumentException($msg); |
|
| 61 | } |
||
| 62 | |||
| 63 | 3 | return $results; |
|
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * {@inheritdoc} |
||
| 68 | * |
||
| 69 | * @return ZendDb2Connection |
||
| 70 | */ |
||
| 71 | 1 | public function getConnection() |
|
| 75 | } |
||
| 76 |
It seems like the method you are trying to call exists only in some of the possible types.
Let’s take a look at an example:
Available Fixes
Add an additional type-check:
Only allow a single type to be passed if the variable comes from a parameter: