Skip to content

Commit

Permalink
ZF-8944: add unit test and correction for Pdo_Oci
Browse files Browse the repository at this point in the history
git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21101 44c647ce-9c0f-0410-b52a-842ac1e357ba
  • Loading branch information
mikaelkael committed Feb 19, 2010
1 parent 87757a3 commit 4ef9ecf
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
21 changes: 21 additions & 0 deletions library/Zend/Db/Statement/Pdo/Oci.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,25 @@ public function fetchAll($style = null, $col = null)
}
return $results;
}


/**
* Fetches a row from the result set.
*
* @param int $style OPTIONAL Fetch mode for this fetch operation.
* @param int $cursor OPTIONAL Absolute, relative, or other.
* @param int $offset OPTIONAL Number for absolute or relative cursors.
* @return mixed Array, object, or scalar depending on fetch mode.
* @throws Zend_Db_Statement_Exception
*/
public function fetch($style = null, $cursor = null, $offset = null)
{
$row = parent::fetch($style, $cursor, $offset);

if (is_array($row) && array_key_exists('zend_db_rownum', $row)) {
unset($row['zend_db_rownum']);
}

return $row;
}
}
31 changes: 31 additions & 0 deletions tests/Zend/Db/Table/Select/TestCommon.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,37 @@ public function testAssembleDbTableUnionSelect()
$selectUnionSql = $selectUnion->assemble();
}

/**
* Test the Adapter's fetchRow() method with a select with offset
* @group ZF-8944
*/
public function testAdapterFetchRowWithOffset()
{
$table = $this->_getSelectTable('products');
$products = $this->_db->quoteIdentifier('zfproducts');
$product_id = $this->_db->quoteIdentifier('product_id');

// Grab the first two rows
$data[0] = $this->_db->fetchRow("SELECT * from $products WHERE $product_id = 1");
$data[1] = $this->_db->fetchRow("SELECT * from $products WHERE $product_id = 2");

$select = $table->select();
$select->order('product_id');
$select->limit(1, 0);

$row = $this->_db->fetchRow($select);

$this->assertEquals($data[0], $row);

$select = $table->select();
$select->order('product_id');
$select->limit(1, 1);

$row = $this->_db->fetchRow($select);

$this->assertEquals($data[1], $row);
}

// ZF-3239
// public function testFromPartIsAvailableRightAfterInstantiation()
// {
Expand Down

0 comments on commit 4ef9ecf

Please sign in to comment.