Skip to content

Commit

Permalink
Add Cake\Database\Query::disableBufferedResults().
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad committed Nov 1, 2018
1 parent 1a91ee7 commit 631e7df
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
16 changes: 16 additions & 0 deletions src/Database/Query.php
Expand Up @@ -2069,6 +2069,22 @@ public function enableBufferedResults($enable = true)
return $this; return $this;
} }


/**
* Disables buffered results.
*
* Disabling buffering will consume less memory as fetched results are not
* remembered for future iterations.
*
* @return $this
*/
public function disableBufferedResults()
{
$this->_dirty();
$this->_useBufferedResults = false;

return $this;
}

/** /**
* Returns whether buffered results are enabled/disabled. * Returns whether buffered results are enabled/disabled.
* *
Expand Down
4 changes: 2 additions & 2 deletions src/ORM/Behavior/TranslateBehavior.php
Expand Up @@ -334,7 +334,7 @@ public function beforeSave(Event $event, EntityInterface $entity, ArrayObject $o
'foreign_key' => $key, 'foreign_key' => $key,
'model' => $model 'model' => $model
]) ])
->enableBufferedResults(false) ->disableBufferedResults()
->all() ->all()
->indexBy('field'); ->indexBy('field');


Expand Down Expand Up @@ -753,7 +753,7 @@ protected function _findExistingTranslations($ruleSet)
->select(['id', 'num' => 0]) ->select(['id', 'num' => 0])
->where(current($ruleSet)) ->where(current($ruleSet))
->disableHydration() ->disableHydration()
->enableBufferedResults(false); ->disableBufferedResults();


unset($ruleSet[0]); unset($ruleSet[0]);
foreach ($ruleSet as $i => $conditions) { foreach ($ruleSet as $i => $conditions) {
Expand Down

0 comments on commit 631e7df

Please sign in to comment.