Re: DataObject setFrom with array values
| From: | daniel at electroteque dot org | Date: | Thu, 27 Jan 2005 00:59:29 +0000 |
| Subject: | Re: DataObject setFrom with array values | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17196@lists.php.net to get a copy of this message | ||
> 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;
}