我有个人资料页面 View ,用户可以在其中更改当前密码。通过使用 findBySql 和当前 session ,我检查了当前密码是否正确。但是我不知道如何在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()
关于yii - 模型中的更新记录- YII 框架,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20519370/