Skip to content

Commit

Permalink
Add some more doc blocks to BufferedStatement.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Feb 5, 2014
1 parent d90abb8 commit 0813835
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions src/Database/Statement/BufferedStatement.php
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -79,6 +93,9 @@ public function fetchAll($type = 'num') {
return $this->_records;
}

/**
* {@inheritDoc}
*/
public function rowCount() {
if (!$this->_allFetched) {
$counter = $this->_counter;
Expand All @@ -89,6 +106,9 @@ public function rowCount() {
return $this->_count;
}

/**
* {@inheritDoc}
*/
public function rewind() {
$this->_counter = 0;
}
Expand Down

0 comments on commit 0813835

Please sign in to comment.