diff --git a/src/Database/Statement/BufferedStatement.php b/src/Database/Statement/BufferedStatement.php index 9bf07399056..7c5bc79cdc7 100644 --- a/src/Database/Statement/BufferedStatement.php +++ b/src/Database/Statement/BufferedStatement.php @@ -16,6 +16,12 @@ */ namespace Cake\Database\Statement; +/** + * A statement decorator that implements buffered results. + * + * This statement decorator will save fetched results in memory, allowing + * the iterator to be rewound and reused. + */ class BufferedStatement extends StatementDecorator { protected $_count = 0; @@ -38,14 +44,19 @@ public function __construct($statement = null, $driver = null) { $this->_reset(); } - /** - * @param array $params list of values to be bound to query - */ +/** + * Execute the statement and return the results. + * + * @param array $params list of values to be bound to query + */ public function execute($params = null) { $this->_reset(); return parent::execute($params); } +/** + * {@inheritDoc} + */ public function fetch($type = 'num') { if ($this->_allFetched) { $row = ($this->_counter < $this->_count) ? $this->_records[$this->_counter++] : false; @@ -67,6 +78,9 @@ public function fetch($type = 'num') { return $this->_records[] = $record; } +/** + * {@inheritDoc} + */ public function fetchAll($type = 'num') { if ($this->_allFetched) { return $this->_records; @@ -79,6 +93,9 @@ public function fetchAll($type = 'num') { return $this->_records; } +/** + * {@inheritDoc} + */ public function rowCount() { if (!$this->_allFetched) { $counter = $this->_counter; @@ -89,6 +106,9 @@ public function rowCount() { return $this->_count; } +/** + * {@inheritDoc} + */ public function rewind() { $this->_counter = 0; }