Skip to content
Browse files

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

  • Loading branch information...
1 parent f4acc79 commit 7101ecd7428e38a0c2edd1a5f23ab3c37ea48423 @beberlei beberlei committed Nov 3, 2011
View
11 UPGRADE
@@ -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.
+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.
View
12 lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php
@@ -19,15 +19,17 @@
namespace Doctrine\DBAL\Driver\OCI8;
-use \PDO;
+use PDO;
+use IteratorAggregate;
+use Doctrine\DBAL\Driver\Statement;
/**
* The OCI8 implementation of the Statement interface.
*
* @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 @@ public function getIterator()
/**
* {@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 @@ public function fetch($fetchStyle = PDO::FETCH_BOTH)
/**
* {@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);
}
View
9 tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
@@ -303,4 +303,13 @@ public function testQuoteSQLInjection()
$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.");
+ }
}

0 comments on commit 7101ecd

Please sign in to comment.
Something went wrong with that request. Please try again.