Commit a6d3d162 authored by Marco Pivetta's avatar Marco Pivetta

Merge branch 'fix/#2500-#2497-return-false-from-mysqli-statement-when-nothing-is-fetched'

Close #2500
Close #2497
parents 8144e267 f90c0b07
......@@ -242,7 +242,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
{
$values = $this->_fetch();
if (null === $values) {
return null;
return false;
}
if (false === $values) {
......@@ -292,7 +292,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
$rows[] = $row;
}
} else {
while (($row = $this->fetch($fetchMode)) !== null) {
while (($row = $this->fetch($fetchMode)) !== false) {
$rows[] = $row;
}
}
......@@ -306,7 +306,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
public function fetchColumn($columnIndex = 0)
{
$row = $this->fetch(PDO::FETCH_NUM);
if (null === $row) {
if (false === $row) {
return false;
}
......
......@@ -237,6 +237,13 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals('foo', $row[1]);
}
public function testFetchNoResult()
{
self::assertFalse(
$this->_conn->executeQuery('SELECT test_int FROM fetch_table WHERE test_int = ?', [-1])->fetch()
);
}
public function testFetchAssoc()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment