Re: DataObject setFrom with array values

From: Date: Thu, 27 Jan 2005 01:16:09 +0000
Subject: Re: DataObject setFrom with array values
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17197@lists.php.net to get a copy of this message
I read the comment about checking setters after I sent this.. - that is the correct behavior.. Regards Alan On Thu, 2005-01-27 at 11:59 +1100, daniel@electroteque.org wrote: > > This should probably be a warning telling you to override setFrom or > > clean your data before sending it to setFrom. > > > > AFAIR, in pecl/DBDO, it does a trigger_Error(.....,E_USER_WARNING) when > > you try to assign an array to a column. which is probably the way it > > should be done in dataobjects > > > Why should we be overriding within each do with date arrays anyway ? > > > That mod ignores the date array so it'll go through ;) > > function setDate_received($string) { > > $this->fromValue('date_received',$string[y].'-'.$string[m].'-'.$string[d]); > } > > i then preformat the value > > > > > Also this toArray override i have to add into every DO so i can get 2D > arrays for list menus :| > > function toArray($s='%s',$extra = array('')) { > $arr = array(); > $r = parent::toArray($s); > $keys = array_keys($r); > while ($this->fetch()) { > $arr[$this->$keys[0]] = $this->$keys[1]; > } > > if (is_array($extra)) { > $arr = array_merge($extra,$arr); > } > return $arr; > } > > > -- Alan Knowles <alan@akbkhome.com>

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