Commit 02b3575d authored by Marco Pivetta's avatar Marco Pivetta

Merge pull request #766 from deeky666/DBAL-1104

[DBAL-1104] Add support for object hydration in oci8 driver
parents a8f66a29 49cf37af
...@@ -243,11 +243,19 @@ class OCI8Statement implements \IteratorAggregate, Statement ...@@ -243,11 +243,19 @@ class OCI8Statement implements \IteratorAggregate, Statement
public function fetch($fetchMode = null) public function fetch($fetchMode = null)
{ {
$fetchMode = $fetchMode ?: $this->_defaultFetchMode; $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
if ( ! isset(self::$fetchModeMap[$fetchMode])) {
if (PDO::FETCH_OBJ == $fetchMode) {
return oci_fetch_object($this->_sth);
}
if (! isset(self::$fetchModeMap[$fetchMode])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode); throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode);
} }
return oci_fetch_array($this->_sth, self::$fetchModeMap[$fetchMode] | OCI_RETURN_NULLS | OCI_RETURN_LOBS); return oci_fetch_array(
$this->_sth,
self::$fetchModeMap[$fetchMode] | OCI_RETURN_NULLS | OCI_RETURN_LOBS
);
} }
/** /**
...@@ -256,11 +264,21 @@ class OCI8Statement implements \IteratorAggregate, Statement ...@@ -256,11 +264,21 @@ class OCI8Statement implements \IteratorAggregate, Statement
public function fetchAll($fetchMode = null) public function fetchAll($fetchMode = null)
{ {
$fetchMode = $fetchMode ?: $this->_defaultFetchMode; $fetchMode = $fetchMode ?: $this->_defaultFetchMode;
$result = array();
if (PDO::FETCH_OBJ == $fetchMode) {
while ($row = $this->fetch($fetchMode)) {
$result[] = $row;
}
return $result;
}
if ( ! isset(self::$fetchModeMap[$fetchMode])) { if ( ! isset(self::$fetchModeMap[$fetchMode])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode); throw new \InvalidArgumentException("Invalid fetch style: " . $fetchMode);
} }
$result = array();
if (self::$fetchModeMap[$fetchMode] === OCI_BOTH) { if (self::$fetchModeMap[$fetchMode] === OCI_BOTH) {
while ($row = $this->fetch($fetchMode)) { while ($row = $this->fetch($fetchMode)) {
$result[] = $row; $result[] = $row;
......
...@@ -646,12 +646,6 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -646,12 +646,6 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
*/ */
public function testFetchAllStyleObject() public function testFetchAllStyleObject()
{ {
$driverName = $this->_conn->getDriver()->getName();
if (in_array($driverName, array('oci8'), true)) {
$this->markTestSkipped(sprintf('Driver "%s" does not support hydrating data to an object.', $driverName));
}
$this->setupFixture(); $this->setupFixture();
$sql = 'SELECT test_int, test_string, test_datetime FROM fetch_table'; $sql = 'SELECT test_int, test_string, test_datetime FROM fetch_table';
......
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