Commit 0bbb36ec authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-228] Fix bug with PDO::FETCH_BOTH when passed to Statement#fetchAll() in OCI8

parent 3b5ba65b
......@@ -227,8 +227,14 @@ class OCI8Statement implements \IteratorAggregate, Statement
}
$result = array();
if (self::$fetchStyleMap[$fetchStyle] === OCI_BOTH) {
while ($row = $this->fetch($fetchStyle)) {
$result[] = $row;
}
} else {
oci_fetch_all($this->_sth, $result, 0, -1,
self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | OCI_FETCHSTATEMENT_BY_ROW | OCI_RETURN_LOBS);
}
return $result;
}
......
......@@ -83,6 +83,27 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo'), $rows[0]);
}
/**
* @group DBAL-228
*/
public function testPrepareWithFetchAllBoth()
{
$paramInt = 1;
$paramStr = 'foo';
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->prepare($sql);
$this->assertInstanceOf('Doctrine\DBAL\Statement', $stmt);
$stmt->bindParam(1, $paramInt);
$stmt->bindParam(2, $paramStr);
$stmt->execute();
$rows = $stmt->fetchAll(\PDO::FETCH_BOTH);
$rows[0] = array_change_key_case($rows[0], \CASE_LOWER);
$this->assertEquals(array('test_int' => 1, 'test_string' => 'foo', 0 => 1, 1 => 'foo'), $rows[0]);
}
public function testPrepareWithFetchColumn()
{
$paramInt = 1;
......
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