Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/4450' into develop
Browse files Browse the repository at this point in the history
Forward port #4450
  • Loading branch information
weierophinney committed May 9, 2013
2 parents fc735bc + a47515b commit 0057178
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions library/Zend/Db/ResultSet/AbstractResultSet.php
Expand Up @@ -18,7 +18,6 @@

abstract class AbstractResultSet implements Iterator, ResultSetInterface
{

/**
* if -1, datasource is already buffered
* if -2, implicitly disabling buffering in ResultSet
Expand Down Expand Up @@ -58,13 +57,21 @@ abstract class AbstractResultSet implements Iterator, ResultSetInterface
*/
public function initialize($dataSource)
{
// reset buffering
if (is_array($this->buffer)) {
$this->buffer = array();
}

if ($dataSource instanceof ResultInterface) {
$this->count = $dataSource->count();
$this->fieldCount = $dataSource->getFieldCount();
$this->dataSource = $dataSource;
if ($dataSource->isBuffered()) {
$this->buffer = -1;
}
if (is_array($this->buffer)) {
$this->dataSource->rewind();
}
return $this;
}

Expand Down Expand Up @@ -97,6 +104,9 @@ public function buffer()
throw new Exception\RuntimeException('Buffering must be enabled before iteration is started');
} elseif ($this->buffer === null) {
$this->buffer = array();
if ($this->dataSource instanceof ResultInterface) {
$this->dataSource->rewind();
}
}
return $this;
}
Expand Down Expand Up @@ -211,7 +221,6 @@ public function valid()
$key = key($this->dataSource);
return ($key !== null);
}

}

/**
Expand Down

0 comments on commit 0057178

Please sign in to comment.