╃巡洋艦㊣
- ╃巡洋艦㊣ 赞了说说发的说说被踩多了会怎样?
- ╃巡洋艦㊣ 赞了说说签到!我要去vip群
- ╃巡洋艦㊣ 赞了回答
先说说你这段代码吧.
$user_model= new User('userxg') ; //这里指定场景,没啥问题 $userxg=$user_model->findByPk($idt); //这里把查询出来的值赋到$userxy,此时的场景已经更改成'updata'. //所以重新指定场景,就可以了. $userxg->scenario = 'userxg'; $userxg->attributes=$_POST['User']; ...
- ╃巡洋艦㊣ 赞了回答
class ActiveRecord 的子类 /** * 保存前 * @param bool $insert 是否insert操作 * @return bool */ public function beforeSave($insert) { if (parent::beforeSave($insert)) { if($insert) { $this->create_user = $this->update_user = Yii::$app->user->id; $this->create_time = $this->update_time = time(); } else { $this->update_time = time(); $this->update_user = Yii::$app->user->id; } return true; } else { return false; } }
- ╃巡洋艦㊣ 赞了说说未语泪先流 感冒了 ~.~
- ╃巡洋艦㊣ 赞了说说不知不觉已签到一个月
- ╃巡洋艦㊣ 赞了回答
使用它
TimestampBehavior
能帮助到你use yii\db\Expression; public function behaviors() { return [ [ 'class' => TimestampBehavior::className(), 'createdAtAttribute' => 'create_time',// 自己根据数据库字段修改 'updatedAtAttribute' => 'update_time', // 自己根据数据库字段修改 'value' => time(), // 自己根据数据库字段修改 ], ]; }