Zend\Db\ResultSet\ResultSet->current() returns false instead of NULL
Closed this issue · 9 comments
This problem was there in version 2.7. It was fixed in 2.8, but came back in 2.9.
- Database: 10.0.35-MariaDB
- PHP version: 7.2.7
- Zend Db version: 2.9.3
To reproduce, use a database with some empty table, and execute:
$myAdapter = new \Zend\Db\Adapter\Adapter([
'host' => 'mariadb',
'driver' => 'Mysqli',
'username' => 'devppl',
'password' => '******',
'database' => 'mydatabase',
'charset' => 'utf8',
'options' => ['buffer_results' => true]
]);
$tableGateway = new \Zend\Db\TableGateway\TableGateway('myEmptyTable', $myAdapter);
$row = $tableGateway->select('myField = 999')->current();
var_export($row);
Expected result would be NULL, I get false instead.
I noticed that when I set buffer_results to false, I don't have the bug.
I think the commit that actually broke the fonctionnality is this one, it returns false in there and it should not because the signature says it should be null (or array):
@willy0275 I confirm this bug has been introduce by #255 and released in 2.9.0. I'm working on a fix.
After a quick look, it seems like the same resulting bug but not the same bug as the method HydratingResultSet->current() is not using the code in the abstract class. So it seems it's just a coincidence and not really related.
Looks great, thanks!
@willy0275 it seems there are some inconsistencies for other adapter, apart Mysqli. I'm working on it and let you know asap.