[dev] [commits] Horde branch master updated. 413405d0e327265fc040114808380c4711010d0f

Michael J Rubinsky mrubinsk at horde.org
Thu Aug 4 15:38:31 UTC 2011


Quoting Vilius Šumskas <vilius at lnk.lt>:

>> Quoting Jan Schneider <jan at horde.org>:
>>
>> > commit 52d22e69b9d98df64bd8450a9c389b53d7e5c6f6
>> > Author: Vilius E umskas <vilius at lnk.lt>
>> > Date:   Thu Jul 21 22:40:22 2011 +0300
>> >
>> >     Use factory and convert to Horde_Db at the same time.
>> >
>> >     I still think Horde_Db needs selectAssoc() badly which would work
>> >     on more than two columns. I spent hours trying to figure out how
>> >     to refactor some code to use indexed arrays.
>>
>> Didn't look at your code yet, but FWIW, what I've been doing in these
>> cases is building the hash in the application's driver code. A good
>> bit of the time there are other things that needed to be done in the
>> loop anyway, e.g., driver field => application field translations.
>> This gives more control over what keys to use, and potentially saves
>> extra loops since to build the hash structure in the db layer, you
>> would need to iterate the results anyway.
>
> I'm not sure this is a very good idea in Agora, as it uses pretty  
> large arrays of data. Doubling that data could hurt performance and  
> memory usage. Or do I just misunderstood you?

$sql = 'SELECT field_one, field_two, field_three FROM some_table';
$rows = $db->selectAll($sql);
$results = array();
foreach ($rows as $row) {
     // Do some other operation on data
     // possibly translate field names to application keys, etc...
     // $this->_fromDriver($row);
     $results[$row['field_one']] = $row;
}
// If you want to get rid of the $rows data before exiting this method;
unset($rows);

If datasize is *really* a concern, you should be paging the queries or  
otherwise limiting the returned data size anyway.

-- 
mike

The Horde Project (www.horde.org)
mrubinsk at horde.org



More information about the dev mailing list