Commit 2c10252b authored by Benjamin Eberlei's avatar Benjamin Eberlei

[DBAL-339] Prevent PDO API failure in setFetchMode()

parent 7a657fa8
......@@ -190,6 +190,12 @@ class Statement implements \IteratorAggregate, DriverStatement
public function setFetchMode($fetchMode, $arg2 = null, $arg3 = null)
{
if ($arg2 === null) {
return $this->stmt->setFetchMode($fetchMode);
} else if ($arg3 === null) {
return $this->stmt->setFetchMode($fetchMode, $arg2);
}
return $this->stmt->setFetchMode($fetchMode, $arg2, $arg3);
}
......
......@@ -501,6 +501,21 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertFalse($this->_conn->query('SELECT test_int FROM fetch_table')->fetchColumn());
}
/**
* @group DBAL-339
*/
public function testSetFetchModeOnDbalStatement()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
$stmt = $this->_conn->executeQuery($sql, array(1, "foo"));
$stmt->setFetchMode(\PDO::FETCH_NUM);
while ($row = $stmt->fetch()) {
$this->assertTrue(isset($row[0]));
$this->assertTrue(isset($row[1]));
}
}
private function setupFixture()
{
$this->_conn->executeQuery('DELETE FROM fetch_table')->execute();
......
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