Yii Framework Forum: Where should I put parent::beforeSave() of a model? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Where should I put parent::beforeSave() of a model? beginning or end ? Rate Topic: -----

#1 User is offline   reed1 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 23-June 10

Posted 22 October 2010 - 11:09 PM

I'm confused

protected function beforeSave()
{
   $this->update = ..
   $this->create = ..
		
   return parent::beforeSave();
}


or

protected function beforeSave()
{
   if (!parent::beforeSave())
      return false;

   $this->update = ..
   $this->create = ..
		
   return true;
}


the same goes to afterFind, init, beforeValidate, etc etc..

please help, thank you
0

#2 User is offline   andy_s 

  • Random Member Title
  • Yii
  • Group: Moderators
  • Posts: 1,526
  • Joined: 22-June 09
  • Location:Russia, Kostroma

Posted 23 October 2010 - 02:40 AM

beforeSave() raises "onBeforeSave" event, so if you have any event's handlers, they will be executed. Now you can answer the question by yourself (it depends on your needs) :)
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users