Commit 7101ecd7 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Work a little bit on the setFetchMode()/traversable patch from damz

parent f4acc79a
......@@ -3,4 +3,13 @@
## Doctrine\DBAL\Connection#insert and Doctrine\DBAL\Connnection#update
Both methods now accept an optional last parameter $types with binding types of the values passed.
This can potentially break child classes that have overwritten one of these methods.
\ No newline at end of file
This can potentially break child classes that have overwritten one of these methods.
## Doctrine\DBAL\Connection#executeQuery
Doctrine\DBAL\Connection#executeQuery() got a new last parameter "QueryCacheProfile $qcp"
## Doctrine\DBAL\Driver\Statement split
The Driver statement was split into a ResultStatement and the normal statement extending from it.
This seperates the configuration and the retrieval API from a statement.
......@@ -19,7 +19,9 @@
namespace Doctrine\DBAL\Driver\OCI8;
use \PDO;
use PDO;
use IteratorAggregate;
use Doctrine\DBAL\Driver\Statement;
/**
* The OCI8 implementation of the Statement interface.
......@@ -27,7 +29,7 @@ use \PDO;
* @since 2.0
* @author Roman Borschel <roman@code-factory.org>
*/
class OCI8Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
class OCI8Statement implements \IteratorAggregate, Statement
{
/** Statement handle. */
protected $_dbh;
......@@ -204,8 +206,9 @@ class OCI8Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Stateme
/**
* {@inheritdoc}
*/
public function fetch($fetchStyle = PDO::FETCH_BOTH)
public function fetch($fetchStyle = null)
{
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle;
if ( ! isset(self::$fetchStyleMap[$fetchStyle])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle);
}
......@@ -216,8 +219,9 @@ class OCI8Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Stateme
/**
* {@inheritdoc}
*/
public function fetchAll($fetchStyle = PDO::FETCH_BOTH)
public function fetchAll($fetchStyle = null)
{
$fetchStyle = $fetchStyle ?: $this->_defaultFetchStyle;
if ( ! isset(self::$fetchStyleMap[$fetchStyle])) {
throw new \InvalidArgumentException("Invalid fetch style: " . $fetchStyle);
}
......
......@@ -303,4 +303,13 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals(0, count($rows), "no result should be returned, otherwise SQL injection is possible");
}
public function testSetDefaultFetchMode()
{
$stmt = $this->_conn->query("SELECT * FROM fetch_table");
$stmt->setFetchMode(\PDO::FETCH_NUM);
$row = array_keys($stmt->fetch());
$this->assertEquals(0, count( array_filter($row, function($v) { return ! is_numeric($v); })), "should be no non-numerical elements in the result.");
}
}
\ No newline at end of file
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