difference between $model->update() and $model->save()


what is the difference between $model->update() and $model->save() ?

i ask this because i have some cases that $model->save() didn’t make update and generate error, but i replace it by $model->update() so it works perfectly.

For this kind of questions… it’s best to check the source code…

In the class reference - http://www.yiiframew…ord#save-detail - where the link to the source code file is… just click on "show"

You will see that the save() method first validates the model… and then depending whether the record is new it calls insert() or update()

So for your case… seems that with save() some validation rule fails and that is the reason why your data is not updated… by calling update() yii saves your data but does not validate it (you can check the source here - http://www.yiiframew…d#update-detail )