Re: toArray was DB_DataObjects and generating search filters

From: Date: Fri, 22 Apr 2005 06:18:53 +0000
Subject: Re: toArray was DB_DataObjects and generating search filters
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18908@lists.php.net to get a copy of this message
> I've added the following function to my DB_DataObject: > > function toArrayList () > { > $list = array(); > while ($this->fetch()) { > $list[] = $this; > } > return $list; > } > > This is pretty useful for me. In the program I just write > > $person = DB_DataObject::factory('person'); > $query = "SELECT ... foo ... bar..."; > $person->query($query); > $smartyRenderer->setAttribute('persons', $person->toArrayList()); > > So first you build the dataobject, write the find / get / query, then > just call toArrayList() then you have a list of the DOs. This works for > very well for me; however, I would appreciate if the original > DB_DataObject would have this, written in a more professional way. > > Laszlo. Interesting , i've been tweeking it alot lately, should i add this, and then forward as a feature request ? Let me do some tests on it first, isnt $this returning the object though ? If you see my example, i want the key as the options value and the second column in the select statement as the select value

« previous php.pear.general (#18908) next »