它在这个函数中返回什么返回parent :: beforeSave();?

时间:2012-05-18 05:13:53

标签: yii

我不知道这个函数会返回什么,只是修改了记录属性或其他任何东西?

protected function beforeSave()
{
    if ($this->getIsNewRecord())
    {
        $this->created = Yii::app()->localtime->UTCNow;
    }             
     $this->lastmodified = Yii::app()->localtime->UTCNow;

     if ($this->dob == '') {
         $this->setAttribute('dob', null);
     } else {
        $this->dob=date('Y-m-d', strtotime($this->dob));
     }
     if($this->image!="")
     {
        $this->imgfile_name =  $this->image->name;
        $this->imgfile_type =  $this->image->type;
        $this->imgfile_size =  $this->image->size;
     }  
     $this->phone=substr($this->phone,0,3).substr($this->phone,4,3).substr($this->phone,8,4);

    return parent::beforeSave();
}

1 个答案:

答案 0 :(得分:1)

如果模型处于有效状态且可以保存,则

CActiveRecord::beforeSave应返回true,如果不存在,则false