Skip to content
Permalink
Browse files

Add Cake\ORM\Query::disableHydration().

  • Loading branch information...
ADmad committed Nov 1, 2018
1 parent c6d7423 commit bc8c37f5e51f0c82d8fc9537ac424475bd915922
@@ -114,7 +114,7 @@ public function read($id)
->find('all')
->select(['data'])
->where([$this->_table->getPrimaryKey() => $id])
->enableHydration(false)
->disableHydration()
->first();
if (empty($result)) {
@@ -752,7 +752,7 @@ protected function _findExistingTranslations($ruleSet)
$query = $association->find()
->select(['id', 'num' => 0])
->where(current($ruleSet))
->enableHydration(false)
->disableHydration()
->enableBufferedResults(false);
unset($ruleSet[0]);
@@ -837,7 +837,7 @@ protected function _recoverTree($counter = 0, $parentId = null, $level = -1)
->select([$aliasedPrimaryKey])
->where([$this->_table->aliasField($parent) . ' IS' => $parentId])
->order($order)
->enableHydration(false);
->disableHydration();
$leftCounter = $counter;
$nextLevel = $level + 1;
@@ -1010,6 +1010,22 @@ public function enableHydration($enable = true)
return $this;
}
/**
* Disable hydrating entities.
*
* Disabling hydration will cause array results to be returned for the query
* instead of entities.
*
* @return $this
*/
public function disableHydration()
{
$this->_dirty();
$this->_hydrate = false;
return $this;
}
/**
* Returns the current hydration mode.
*
@@ -1797,7 +1797,7 @@ public function exists($conditions)
->select(['existing' => 1])
->where($conditions)
->limit(1)
->enableHydration(false)
->disableHydration()
->toArray()
);
}
@@ -571,7 +571,7 @@ public function testBelongsToManyEagerLoadingNoHydration($strategy)
]);
$query = new Query($this->connection, $table);
$results = $query->select()->contain('Tags')->enableHydration(false)->toArray();
$results = $query->select()->contain('Tags')->disableHydration()->toArray();
$expected = [
[
'id' => 1,
@@ -632,7 +632,7 @@ public function testBelongsToManyEagerLoadingNoHydration($strategy)
$results = $query->select()
->contain(['Tags' => ['conditions' => ['Tags.id' => 3]]])
->enableHydration(false)
->disableHydration()
->toArray();
$expected = [
[
@@ -685,7 +685,7 @@ public function testFilteringByHasManyNoHydration()
$results = $query->repository($table)
->select()
->enableHydration(false)
->disableHydration()
->matching('Comments', function ($q) {
return $q->where(['Comments.user_id' => 4]);
})

0 comments on commit bc8c37f

Please sign in to comment.
You can’t perform that action at this time.