errors[$field] = $text; } public function getErrors() { return $this->errors; } public function update() { // reset the errors array $this->errors = array(); // begin transaction before the update $this->bean->begin(); } public function after_update() { if(count($this->errors) > 0) { $this->bean->rollback(); throw new Exception('validation_failed'); } } }