0

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

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();
}
4

1 回答 1

1

CActiveRecord::beforeSavetrue如果模型处于有效状态并且可以保存,则应该返回,否则返回false

于 2012-05-18T19:56:03.837 回答