首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

yiif的Behavior例子

2012-09-09 
yiif的Behavior事例?phpclass AutoTimestampBehavior extends CActiveRecordBehavior {/*** The field th

yiif的Behavior事例

<?phpclass AutoTimestampBehavior extends CActiveRecordBehavior {     /**    * The field that stores the creation time    */    public $created = 'created';    /**    * The field that stores the modification time    */    public $modified = 'modified';      public function beforeValidate($on) {        if ($this->Owner->isNewRecord)            $this->Owner->{$this->created} = new CDbExpression('NOW()');        else            $this->Owner->{$this->modified} = new CDbExpression('NOW()');         return true;        }}

?

model:

public function behaviors(){    return array(        'AutoTimestampBehavior' => array(            'class' => 'application.components.AutoTimestampBehavior',            //You can optionally set the field name options here        )    );}
?

热点排行