Reputation: 69
I have profile page view where user can change the current password. By using findBySql & current session I checked whether the current password is correct. But I don't know how to update the records in the model in yii framework.
Upvotes: 7
Views: 27395
Reputation: 5716
You can simply follow this way to update a record in yii.
$user = User::model()->findByPk($userId);
$user->username = 'hello world';
$user->password = 'password';
$user->update();
How to save a new record in yii ?
$user = new User();
$user->username = 'hello world';
$user->password = 'password';
$user->save();
How to delete a record in yii ?
$user = User::model()->findByPk($userId);
$user->delete()
Upvotes: 15
Reputation: 17
If you want to pop-up message, may you can try with Ajax validation, or Javascript to pop-up a window, after your validation ?
Upvotes: 0
Reputation: 7985
Please read about yii active record this is a good resource http://www.yiiframework.com/doc/guide/1.1/en/database.ar
It is usually as simple as that:
$user = User::model()->findByPk($userId);
$user->password = 'new_password';
$user->save();
Upvotes: 0