Re: toArray was DB_DataObjects and generating search filters

From: Date: Thu, 21 Apr 2005 21:18:43 +0000
Subject: Re: toArray was DB_DataObjects and generating search filters
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18899@lists.php.net to get a copy of this message
On 4/21/05, Dan Rossi <pear@electroteque.org> wrote: > > On 22/04/2005, at 2:56 AM, Justin Patrin wrote: > > > On 4/20/05, pear@electroteque.org <pear@electroteque.org> wrote: > >> Ok this is how i currently have to setup a method to return an array > >> for > >> list menus as u can see the code is duplicating. toArray returns keys > >> as > >> 0,1,2,3,4,5,6,7 etc ... > >> > >> keys need to be the primary keys :| > >> > >> function getDepartments() > >> { > >> $this->orderBy('department'); > >> $this->find(); > >> $arr = array(); > >> $arr[''] = ""; > >> while ($this->fetch()) { > >> $arr[$this->departmentID] = $this->department; > >> } > >> return $arr; > >> } > >> > > > > Did you have a question? > > > > -- > > > > LOL yes , is there a more formulated way already without having to > duplicate code ? > Well...I'm not sure what you're asking here. toArray() returns an assoc array of the current record, not a list of records... and it certainly doesn't have numbered indexes. Which code are you supposedly duplicating? -- Justin Patrin

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