From 6ce5609874adb80385c2ab4d8969b3199ae9b46f Mon Sep 17 00:00:00 2001 From: Jose Lorenzo Rodriguez Date: Wed, 7 Jan 2015 23:22:31 +0100 Subject: [PATCH] Moving bufferResults from the ORM to Database Query --- src/Database/Query.php | 35 +++++++++++++++++++++++++++++++++++ src/ORM/Query.php | 35 ----------------------------------- 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/src/Database/Query.php b/src/Database/Query.php index 933fed1eb55..e861181f3bb 100644 --- a/src/Database/Query.php +++ b/src/Database/Query.php @@ -113,6 +113,14 @@ class Query implements ExpressionInterface, IteratorAggregate */ protected $_functionsBuilder; + /** + * Boolean for tracking whether or not buffered results + * are enabled. + * + * @var bool + */ + protected $_useBufferedResults = true; + /** * Constructor. * @@ -1581,6 +1589,33 @@ public function valueBinder($binder = null) return $this; } + /** + * Enable/Disable buffered results. + * + * When enabled the results returned by this Query will be + * buffered. This enables you to iterate a result set multiple times, or + * both cache and iterate it. + * + * When disabled it will consume less memory as fetched results are not + * remembered for future iterations. + * + * If called with no arguments, it will return whether or not buffering is + * enabled. + * + * @param bool $enable whether or not to enable buffering + * @return bool|$this + */ + public function bufferResults($enable = null) + { + if ($enable === null) { + return $this->_useBufferedResults; + } + + $this->_dirty(); + $this->_useBufferedResults = (bool)$enable; + return $this; + } + /** * Auxiliary function used to wrap the original statement from the driver with * any registered callbacks. diff --git a/src/ORM/Query.php b/src/ORM/Query.php index 06bdba805a4..0c387a17953 100644 --- a/src/ORM/Query.php +++ b/src/ORM/Query.php @@ -76,14 +76,6 @@ class Query extends DatabaseQuery implements JsonSerializable */ protected $_autoFields; - /** - * Boolean for tracking whether or not buffered results - * are enabled. - * - * @var bool - */ - protected $_useBufferedResults = true; - /** * Whether to hydrate results into entity objects * @@ -343,33 +335,6 @@ public function matching($assoc, callable $builder = null) return $this; } - /** - * Enable/Disable buffered results. - * - * When enabled the ResultSet returned by this Query will be - * buffered. This enables you to iterate a ResultSet multiple times, or - * both cache and iterate the ResultSet. - * - * When disabled it will consume less memory as fetched results are not - * remembered in the ResultSet. - * - * If called with no arguments, it will return whether or not buffering is - * enabled. - * - * @param bool $enable whether or not to enable buffering - * @return bool|$this - */ - public function bufferResults($enable = null) - { - if ($enable === null) { - return $this->_useBufferedResults; - } - - $this->_dirty(); - $this->_useBufferedResults = (bool)$enable; - return $this; - } - /** * Returns a key => value array representing a single aliased field * that can be passed directly to the select() method.