我正在編寫一個symfony 1.4應用程序,並試圖設置將在編輯對象時特定值發生更改時運行的代碼。如何獲得symfony保存方法內的原始值?
我想在模型類內部而不是在視圖內部執行此操作,因爲無論何時保存此對象,此操作都會生效。
在用戶做出任何更改之前,有沒有辦法訪問對象的原始值?
注:
的對象尚未保存,因此它仍然是可能的(不知何故)檢索原始值。
CODE:
public function save()
{
if($this->isNew())
$this->getAcctRelatedByAccountId()->updateCurrentBalance(($this->isAdditive()) ? $this->getAmount(): $this->getAmount()*-1);
// get the original value HERE
// do work based on the original value
// do work based on the new, submitted value
return parent::save();
}
我的項目是使用Propel,有沒有類似的東西? – Patrick 2011-04-14 03:58:10
哦,我不知道。我對Propel ORM知之甚少。 – cuhuak 2011-04-18 06:22:50