12345678910111213141516171819202122232425262728293031323334353637383940 |
- <?php
- /**
- * Created by PhpStorm.
- * User: xiaofeng
- * Date: 2018/4/18
- * Time: 下午7:46
- */
- namespace common\models;
- use yii\db\ActiveRecord;
- use yii\behaviors\TimestampBehavior;
- class Common extends ActiveRecord
- {
- protected $setDel = 1;
- public function behaviors()
- {
- return [
- [
- 'class' => TimestampBehavior::className(),
- 'attributes' => [
- # 创建之前
- ActiveRecord::EVENT_BEFORE_INSERT => ['create_at', 'update_at'],
- # 修改之前
- ActiveRecord::EVENT_BEFORE_UPDATE => ['update_at']
- ],
- #设置默认值
- 'value' => $_SERVER['REQUEST_TIME']
- ]
- ];
- }
- public function setDelete($num)
- {
- $this->setDel = $num;
- }
- }
|