-
☆ A M B ☆
- 3,141 Posts
I'd recommend using beforeSet in the create/update processors as well, and slightly rewrite it to..
public function beforeSet(){
$from_name = trim($this->getProperty('msg_from_name'));
$from_addr = trim($this->getProperty('msg_from_addr'));
$from = !empty($from_name) ? $from_addr.'|'.$from_name : $from_addr ;
$reply_name = trim($this->getProperty('msg_reply_name'));
$reply_addr = trim($this->getProperty('msg_reply_addr'));
$replyto = !empty($reply_name) ? $reply_addr.'|'.$reply_name : $reply_addr ;
$this->setProperty('msg_from',$from);
$this->setProperty('msg_replyto',$replyto);
$this->unsetProperty('msg_from_name');
$this->unsetProperty('msg_from_addr');
$this->unsetProperty('msg_reply_name');
$this->unsetProperty('msg_reply_addr');
return parent::beforeSet();
}
but that's not more than semantics.
One thing I'm not certain of is whether I'm using unsetProperty() on the correct object ... but I don't seem to be getting any db errors.
xPDO is smart enough to look at the table schema before adding non-existant fields to the generated SQL query.