Commit def638ff authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-241] Added platform independent test for Statement#fetchAll(PDO::FETCH_COLUMN)

parent 118e36f7
......@@ -226,7 +226,6 @@ class OCI8Statement implements \IteratorAggregate, Statement
if ( ! isset(self::$fetchStyleMap[$fetchStyle])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle);
}
<<<<<<< HEAD
$result = array();
if (self::$fetchStyleMap[$fetchStyle] === OCI_BOTH) {
......@@ -234,22 +233,17 @@ class OCI8Statement implements \IteratorAggregate, Statement
$result[] = $row;
}
} else {
oci_fetch_all($this->_sth, $result, 0, -1,
self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | OCI_FETCHSTATEMENT_BY_ROW | OCI_RETURN_LOBS);
=======
$fetchStructure = OCI_FETCHSTATEMENT_BY_ROW;
if ($fetchStyle == PDO::FETCH_COLUMN) {
$fetchStructure = OCI_FETCHSTATEMENT_BY_COLUMN;
}
$fetchStructure = OCI_FETCHSTATEMENT_BY_ROW;
if ($fetchStyle == PDO::FETCH_COLUMN) {
$fetchStructure = OCI_FETCHSTATEMENT_BY_COLUMN;
}
$result = array();
oci_fetch_all($this->_sth, $result, 0, -1,
self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS);
oci_fetch_all($this->_sth, $result, 0, -1,
self::$fetchStyleMap[$fetchStyle] | OCI_RETURN_NULLS | $fetchStructure | OCI_RETURN_LOBS);
if ($fetchStyle == PDO::FETCH_COLUMN) {
$result = $result[0];
>>>>>>> Adding PDO::FETCH_COLUMN support to OCI8 fetchAll method using the fetch structure OCI_FETCHSTATEMENT_BY_COLUMN.
if ($fetchStyle == PDO::FETCH_COLUMN) {
$result = $result[0];
}
}
return $result;
......
......@@ -434,6 +434,23 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals('foo', $results[0]->test_string);
$this->assertStringStartsWith('2010-01-01 10:10:10', $results[0]->test_datetime);
}
/**
* @group DBAL-241
*/
public function testFetchAllStyleColumn()
{
$sql = "DELETE FROM fetch_table";
$this->_conn->executeUpdate($sql);
$this->_conn->insert('fetch_table', array('test_int' => 1, 'test_string' => 'foo'));
$this->_conn->insert('fetch_table', array('test_int' => 10, 'test_string' => 'foo'));
$sql = "SELECT test_int FROM fetch_table";
$rows = $this->_conn->query($sql)->fetchAll(\PDO::FETCH_COLUMN);
$this->assertEquals(array(1, 10), $rows);
}
}
class MyFetchClass
......
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