Events, Behaviors And Event Handlers

Hi,

I am having too much confusion with Events, behaviors and Event handlers.

Using this comment I got an understanding about it.

In that comment to execute an event, in User model class, afterSave() method is used.

User.php (Model):




class User extends CActiveRecord

{

  // some other methods


  public function afterSave()

  {

    if ($this->isNewRecord) 

    {

      if ($this->hasEventHandler('onNewUser')) 

      {

        $event = new CModelEvent($this);

        $this->onNewUser($event);

      }

    }


    parent::afterSave();

  }

  

  

  public function onNewUser($event) 

  {

    $this->raiseEvent('onNewUser', $event);

  }

}



I have a different scenario, in which after a successful transaction I want to send an email to the user.

Could anyone please tell me or give any advice on, how can I process the afterSave() method in my case.

Thanks

hi razor101 I think this article will help you to get started… read this article probably you got a idea on how to do this. <a href="www.yiiframework.com/wiki/481/how-to-implement-an-event-and-attach-it-in-a-behavior/">behaviors and events</a>