Yii 它在这个函数return parent::beforeSave()中返回什么;?
我不知道这个函数会返回什么,只是修改了记录属性还是其他什么Yii 它在这个函数return parent::beforeSave()中返回什么;?,yii,Yii,我不知道这个函数会返回什么,只是修改了记录属性还是其他什么 protected function beforeSave() { if ($this->getIsNewRecord()) { $this->created = Yii::app()->localtime->UTCNow; } $this->lastmodified = Yii::app()->localtime->U
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();
}
如果模型处于有效状态并且可以保存,则应返回
true
,如果模型未处于有效状态,则应返回false
。并且您需要最后一行,以便beforeSave()的父实现也可以启动