Permalink
Browse files

[DBAL-228] Fix bug with PDO::FETCH_BOTH when passed to Statement#fetc…

…hAll() in OCI8
  • Loading branch information...
beberlei committed Mar 14, 2012
1 parent c37d211 commit 95bcdc6316af2eb1a76a4e092f3e5494da603e8f
@@ -227,8 +227,14 @@ public function fetchAll($fetchStyle = null)
}
$result = array();
- oci_fetch_all($this->_sth, $result, 0, -1,
- self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | OCI_FETCHSTATEMENT_BY_ROW | OCI_RETURN_LOBS);
+ 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 @@ public function testPrepareWithFetchAll()
$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;

0 comments on commit 95bcdc6

Please sign in to comment.