2
0
Просмотр исходного кода

ZF-8944: add unit test and correction for Pdo_Oci

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21101 44c647ce-9c0f-0410-b52a-842ac1e357ba
mikaelkael 16 лет назад
Родитель
Сommit
4ef9ecfefa
2 измененных файлов с 52 добавлено и 0 удалено
  1. 21 0
      library/Zend/Db/Statement/Pdo/Oci.php
  2. 31 0
      tests/Zend/Db/Table/Select/TestCommon.php

+ 21 - 0
library/Zend/Db/Statement/Pdo/Oci.php

@@ -66,4 +66,25 @@ class Zend_Db_Statement_Pdo_Oci extends Zend_Db_Statement_Pdo
         }
         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 - 0
tests/Zend/Db/Table/Select/TestCommon.php

@@ -264,6 +264,37 @@ abstract class Zend_Db_Table_Select_TestCommon extends Zend_Db_Select_TestCommon
         $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()
 //    {