Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for DBAL-209 #240

Merged
merged 1 commit into from

3 participants

@nemekzg

Fix for DBAL-209

@doctrinebot
Collaborator

Hello,

thank you for positing this Pull Request. I have automatically opened an issue on our Jira Bug Tracker for you with the details of this Pull-Request. See the Link:

http://doctrine-project.org/jira/browse/DBAL-403

@beberlei beberlei merged commit 31bd153 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 29, 2012
  1. Fix for DBAL-209

    root authored
This page is out of date. Refresh to see the latest.
View
5 lib/Doctrine/DBAL/Connection.php
@@ -577,11 +577,12 @@ public function quote($input, $type = null)
*
* @param string $sql The SQL query.
* @param array $params The query parameters.
+ * @param array $types Query parameter types.
* @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();
}
/**
View
32 tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
@@ -186,6 +186,38 @@ public function testFetchAll()
$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()
{
$sql = "SELECT test_int, test_string FROM fetch_table WHERE test_int = ? AND test_string = ?";
Something went wrong with that request. Please try again.