zendtech / IbmiToolkit

PHP frontend to XMLSERVICE for IBM i development.
BSD 3-Clause "New" or "Revised" License
46 stars 34 forks source link

PDO transport error when fetch mode is FETCH_ASSOC #184

Closed alanseiden closed 1 year ago

alanseiden commented 1 year ago

When a PDO connection is set up with: PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC and passed to the toolkit for use, an error will later arise stating that index 0 was not found: Undefined array key 0

The error occurs on this line: https://github.com/zendtech/IbmiToolkit/blob/85bd8b9ba9c2fd3b3d06544f850a4c74a258bcde/ToolkitApi/PdoSupp.php#L151

The logic in PdoSupp presumes numeric indexes in looking for index 0. Note that index 0 is the only array element obtained from $result, so we could probably get the first array element in another manner. Either use: $tmp = current($result); or $tmp = reset($result);

alanseiden commented 1 year ago

Fixed with #185