Commit 4566773b authored by root's avatar root

Fix for DBAL-209

parent 74c76161
...@@ -577,11 +577,12 @@ class Connection implements DriverConnection ...@@ -577,11 +577,12 @@ class Connection implements DriverConnection
* *
* @param string $sql The SQL query. * @param string $sql The SQL query.
* @param array $params The query parameters. * @param array $params The query parameters.
* @param array $types Query parameter types.
* @return array * @return array
*/ */
public function fetchAll($sql, array $params = array()) public function fetchAll($sql, array $params = array(), $types = array())
{ {
return $this->executeQuery($sql, $params)->fetchAll(); return $this->executeQuery($sql, $params, $types)->fetchAll();
} }
/** /**
......
...@@ -186,6 +186,38 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -186,6 +186,38 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->assertEquals('foo', $row['test_string']); $this->assertEquals('foo', $row['test_string']);
} }
/**
* @group DBAL-209
*/
public function testFetchAllWithTypes()
{
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$data = $this->_conn->fetchAll($sql, array(1, $datetime), array(PDO::PARAM_STR, Type::DATETIME));
$this->assertEquals(1, count($data));
$row = $data[0];
$this->assertEquals(2, count($row));
$row = array_change_key_case($row, \CASE_LOWER);
$this->assertEquals(1, $row['test_int']);
$this->assertEquals($datetimeString, $row['test_datetime']);
}
/**
* @group DBAL-209
* @expectedException \Doctrine\DBAL\DBALException
*/
public function testFetchAllWithMissingTypes()
{
$datetimeString = '2010-01-01 10:10:10';
$datetime = new \DateTime($datetimeString);
$sql = "SELECT test_int, test_datetime FROM fetch_table WHERE test_int = ? AND test_datetime = ?";
$data = $this->_conn->fetchAll($sql, array(1, $datetime));
}
public function testFetchBoth() public function testFetchBoth()
{ {
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?"; $sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
......
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