← Back to team overview

anewt-developers team mailing list archive

[Branch ~uws/anewt/anewt.uws] Rev 1788: [autorecord] Avoid double loops when instantiating objects

 

------------------------------------------------------------
revno: 1788
committer: Wouter Bolsterlee <uws@xxxxxxxxx>
branch nick: anewt
timestamp: Sat 2010-10-02 15:12:10 +0200
message:
  [autorecord] Avoid double loops when instantiating objects 
  
  Don't use AnewtDatabaseConnection convenience API, but build
  AutoRecord instances while looping through the result set.
  
  Fixes lp:640803.
modified:
  autorecord/autorecord.lib.php


--
lp:anewt
https://code.launchpad.net/~uws/anewt/anewt.uws

Your team Anewt developers is subscribed to branch lp:anewt.
To unsubscribe from this branch go to https://code.launchpad.net/~uws/anewt/anewt.uws/+edit-subscription
=== modified file 'autorecord/autorecord.lib.php'
--- autorecord/autorecord.lib.php	2010-10-02 13:02:32 +0000
+++ autorecord/autorecord.lib.php	2010-10-02 13:12:10 +0000
@@ -949,8 +949,19 @@
 		}
 		else
 		{
-			$rows = $connection->prepare_execute_fetch_all('?raw?', $sql_full);
-			return AnewtAutoRecord::_db_objects_from_arrays($class, $rows);
+			$out = array();
+			$rs = $connection->prepare('?raw?')->executev(array($sql_full));
+			while (true)
+			{
+				$row = $rs->fetch_one();
+
+				if (!$row)
+					break;
+
+				$out[] = AnewtAutoRecord::_db_object_from_array($class, $row);
+			}
+			$rs->free();
+			return $out;
 		}
 	}