Commit 6ed2e63d authored by romanb's avatar romanb

added hydration mode HYDRATE_NONE

parent 1ac6d509
...@@ -359,6 +359,11 @@ final class Doctrine ...@@ -359,6 +359,11 @@ final class Doctrine
* HYDRATE_ARRAY * HYDRATE_ARRAY
*/ */
const HYDRATE_ARRAY = 3; const HYDRATE_ARRAY = 3;
/**
* HYDRATE_NONE
*/
const HYDRATE_NONE = 4;
/** /**
* VALIDATION CONSTANTS * VALIDATION CONSTANTS
......
...@@ -882,7 +882,7 @@ class Doctrine_Hydrate extends Doctrine_Locator_Injectable implements Serializab ...@@ -882,7 +882,7 @@ class Doctrine_Hydrate extends Doctrine_Locator_Injectable implements Serializab
if (is_integer($stmt)) { if (is_integer($stmt)) {
return $stmt; return $stmt;
} }
$array = $this->parseData2($stmt, $hydrationMode); $array = $this->parseData2($stmt, $hydrationMode);
} }
return $array; return $array;
...@@ -1024,7 +1024,10 @@ class Doctrine_Hydrate extends Doctrine_Locator_Injectable implements Serializab ...@@ -1024,7 +1024,10 @@ class Doctrine_Hydrate extends Doctrine_Locator_Injectable implements Serializab
*/ */
public function parseData2($stmt, $hydrationMode) public function parseData2($stmt, $hydrationMode)
{ {
if ($hydrationMode == Doctrine::HYDRATE_NONE) {
return $stmt->fetchAll(PDO::FETCH_NUM);
}
$cache = array(); $cache = array();
$rootMap = reset($this->_aliasMap); $rootMap = reset($this->_aliasMap);
$rootAlias = key($this->_aliasMap); $rootAlias = key($this->_aliasMap);
......
...@@ -160,4 +160,17 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase ...@@ -160,4 +160,17 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
$users = $q->execute(array($u->id), Doctrine::HYDRATE_ARRAY); $users = $q->execute(array($u->id), Doctrine::HYDRATE_ARRAY);
$this->assertEqual($users[0]['created'], null); $this->assertEqual($users[0]['created'], null);
} }
public function testHydrateNone()
{
$u = new User();
$u->name = "fetch_array_test";
$u->created = null;
$u->save();
$q = new Doctrine_Query();
$q->select('COUNT(u.id) num')->from('User u')->where('u.id = ?');
$res = $q->execute(array($u->id), Doctrine::HYDRATE_NONE);
$this->assertEqual(1, $res[0][0]);
}
} }
...@@ -240,6 +240,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase ...@@ -240,6 +240,7 @@ class Doctrine_Record_TestCase extends Doctrine_UnitTestCase
$this->connection->clear(); $this->connection->clear();
$user = $this->connection->getTable('User')->find(5); $user = $this->connection->getTable('User')->find(5);
$this->assertEqual($user->name, null); $this->assertEqual($user->name, null);
} }
......
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