Update model entry - YII Framework

I have a profile page view where the user can change the current password. Using findBySql and the current session, I checked if the current password is correct. But I do not know how to update records in the model in the yii structure.

+6
source share
3 answers

You can simply follow this path to update the entry in yii.

$user = User::model()->findByPk($userId); $user->username = 'hello world'; $user->password = 'password'; $user->update(); 

How to save a new entry in yii?

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

How to delete an entry in yii?

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

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 so simple:

 $user = User::model()->findByPk($userId); $user->password = 'new_password'; $user->save(); 
0
source

If you want a popup message, can you try using Ajax or Javascript validation for the popup after validation?

0
source

All Articles