How do I check if field has changed?
I'd like to trigger an action in preSave()
only if specific field has changed, e.q.
public function preSave() {
if ($bodyBefore != $bodyNow) {
$this->html = $this->_htmlify($bodyNow);
}
}
The question is how to get this $bodyBefore
and $bodyNow
Travis's answer was almost right, because the problem is that the object is overwritten when you do the Doctrine query. So the solution is:
Please don't fetch the database again! This works for Doctrine 1.2, I haven't tested lower versions.
Check out the documentation, too.
Try this out.