Skip to content

Commit

Permalink
Fixed Database result cursor bug.
Browse files Browse the repository at this point in the history
  • Loading branch information
ysugimoto committed Sep 18, 2012
1 parent ce3950a commit e29d077
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions seezoo/core/classes/drivers/database/Database_result.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,16 @@ public function result()
{
if ( ! $this->_resultObject )
{
$this->_resultObject = $this->_stmt->fetchAll(PDO::FETCH_OBJ);
// rewind cursor
if ( FALSE != ($first = $this->_stmt->fetch(PDO::FETCH_OBJ, PDO::FETCH_ORI_ABS, 0)) )
{
$this->_resultObject = $this->_stmt->fetchAll(PDO::FETCH_OBJ);
array_unshift($this->_resultObject, $first);
}
else
{
$this->_resultObject = array();
}
$this->_resultCache[PDO::FETCH_OBJ] = $this->_resultObject;
}
return $this->_resultObject;
Expand All @@ -174,7 +183,16 @@ public function resultArray()
{
if ( ! $this->_resultArray )
{
$this->_resultArray = $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
// rewind cursor
if ( FALSE != ($first = $this->_stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 0)) )
{
$this->_resultArray = $this->_stmt->fetchAll(PDO::FETCH_ASSOC);
array_unshift($this->_resultArray, $first);
}
else
{
$this->_resultArray = array();
}
$this->_resultCache[PDO::FETCH_ASSOC] = $this->_resultArray;
}
return $this->_resultArray;
Expand Down

0 comments on commit e29d077

Please sign in to comment.