Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing various faling tests. The problem was not closing the statemen…
…ts, among other things
- Loading branch information
Showing
6 changed files
with
27 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
|
@@ -113,6 +113,13 @@ class ResultSet implements Countable, Iterator, Serializable, JsonSerializable { | ||
*/ | */ | ||
protected $_useBuffering = true; | protected $_useBuffering = true; | ||
|
|
||
/** | |||
* Holds the count of records in this result set | |||
* | |||
* @var integer | |||
*/ | |||
protected $_count; | |||
|
|||
/** | /** | ||
* Constructor | * Constructor | ||
* | * | ||
|
@@ -128,6 +135,10 @@ public function __construct($query, $statement) { | ||
$this->_hydrate = $this->_query->hydrate(); | $this->_hydrate = $this->_query->hydrate(); | ||
$this->_entityClass = $query->repository()->entityClass(); | $this->_entityClass = $query->repository()->entityClass(); | ||
$this->_useBuffering = $query->bufferResults(); | $this->_useBuffering = $query->bufferResults(); | ||
|
|||
if ($statement) { | |||
$this->count(); | |||
} | |||
} | } | ||
|
|
||
/** | /** | ||
|
@@ -199,8 +210,9 @@ public function valid() { | ||
|
|
||
$this->_current = $this->_fetchResult(); | $this->_current = $this->_fetchResult(); | ||
$valid = $this->_current !== false; | $valid = $this->_current !== false; | ||
$hasNext = $this->_index < $this->_count; | |||
|
|
||
if (!$valid && $this->_statement) { | if ($this->_statement && !($valid && $hasNext)) { | ||
$this->_statement->closeCursor(); | $this->_statement->closeCursor(); | ||
} | } | ||
|
|
||
|
@@ -271,10 +283,13 @@ public function first() { | ||
* @return integer | * @return integer | ||
*/ | */ | ||
public function count() { | public function count() { | ||
if ($this->_count !== null) { | |||
return $this->_count; | |||
} | |||
if ($this->_statement) { | if ($this->_statement) { | ||
return $this->_statement->rowCount(); | return $this->_count = $this->_statement->rowCount(); | ||
} | } | ||
return count($this->_results); | return $this->_count = count($this->_results); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
lorenzo
Author
Member
|
|||
} | } | ||
|
|
||
/** | /** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I'm guessing these are workarounds for PDO being sad?