加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

更新model-YII Framework中的记录

发布时间:2020-12-13 18:15:21 所属栏目:PHP教程 来源:网络整理
导读:我有个人资料页面视图,用户可以在其中更改当前密码.通过使用findBySql当前会话我检查了当前密码是否正确.但我不知道如何在yii框架中更新模型中的记录. 您只需按照这种方式更新yii中的记录即可. $user = User::model()-findByPk($userId);$user-username = 'h
我有个人资料页面视图,用户可以在其中更改当前密码.通过使用findBySql&当前会话我检查了当前密码是否正确.但我不知道如何在yii框架中更新模型中的记录.
您只需按照这种方式更新yii中的记录即可.
$user = User::model()->findByPk($userId);
$user->username = 'hello world';
$user->password = 'password';
$user->update();

如何在yii中保存新记录?

$user = new User();
$user->username = 'hello world';
$user->password = 'password';
$user->save();

如何删除yii中的记录?

$user = User::model()->findByPk($userId);
$user->delete()

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读