[limb-svn] r6957 - in 3.x/trunk/limb/dbal: src/drivers tests/cases/driver

svn at limb-project.com svn at limb-project.com
Fri Apr 25 16:29:24 MSD 2008


Author: korchasa
Date: 2008-04-25 16:29:24 +0400 (Fri, 25 Apr 2008)
New Revision: 6957
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6957

Modified:
   3.x/trunk/limb/dbal/src/drivers/lmbDbBaseRecordSet.class.php
   3.x/trunk/limb/dbal/tests/cases/driver/DriverRecordSetTestBase.class.php
Log:
-- added method toFlatArray() to record set

Modified: 3.x/trunk/limb/dbal/src/drivers/lmbDbBaseRecordSet.class.php
===================================================================
--- 3.x/trunk/limb/dbal/src/drivers/lmbDbBaseRecordSet.class.php	2008-04-25 12:28:10 UTC (rev 6956)
+++ 3.x/trunk/limb/dbal/src/drivers/lmbDbBaseRecordSet.class.php	2008-04-25 12:29:24 UTC (rev 6957)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 lmb_require('limb/dbal/src/drivers/lmbDbRecordSet.interface.php');
 
@@ -53,6 +53,14 @@
     return $array;
   }
 
+  function getFlatArray()
+  {
+    $flat_array = array();
+    foreach ($this as $record)
+      $flat_array[] = $record->export();
+    return $flat_array;
+  }
+
   //ArrayAccess interface
   function offsetExists($offset)
   {

Modified: 3.x/trunk/limb/dbal/tests/cases/driver/DriverRecordSetTestBase.class.php
===================================================================
--- 3.x/trunk/limb/dbal/tests/cases/driver/DriverRecordSetTestBase.class.php	2008-04-25 12:28:10 UTC (rev 6956)
+++ 3.x/trunk/limb/dbal/tests/cases/driver/DriverRecordSetTestBase.class.php	2008-04-25 12:29:24 UTC (rev 6957)
@@ -2,9 +2,9 @@
 /*
  * Limb PHP Framework
  *
- * @link http://limb-project.com 
+ * @link http://limb-project.com
  * @copyright  Copyright © 2004-2007 BIT(http://bit-creative.com)
- * @license    LGPL http://www.gnu.org/copyleft/lesser.html 
+ * @license    LGPL http://www.gnu.org/copyleft/lesser.html
  */
 
 abstract class DriverRecordSetTestBase extends UnitTestCase
@@ -88,7 +88,7 @@
     for($this->cursor->rewind(), $i = 0; $this->cursor->valid(); $this->cursor->next(), $i++);
     $this->assertEqual($i, 2);
   }
-  
+
   function testCount()
   {
     $sql = "SELECT * FROM founding_fathers";
@@ -166,6 +166,20 @@
     $this->assertEqual($rs->at(1)->get('first'), 'Alexander');
     $this->assertEqual($rs->at(2)->get('first'), 'George');
   }
+
+  function testGetFlatArray()
+  {
+    $sql = "SELECT first FROM founding_fathers";
+    $rs = $this->connection->newStatement($sql)->getRecordSet();
+
+    $flat_array = array(
+      array('first' => 'George'),
+      array('first' => 'Alexander'),
+      array('first' => 'Benjamin'),
+    );
+
+    $this->assertIdentical($flat_array, $rs->getFlatArray());
+  }
 }
 
 



More information about the limb-svn mailing list