how do I update a single attributes valie?

Hi thre, I can not find in the documentation how to update just a single value:


$mymodel= MyModel::model()->find(‘name=:name’, array(’:name’=>‘fire’));

[size=2] $mymodel->lastname=‘mylastname’;[/size]

[size=2][/size][size=2] $mymodel->update();[/size]

[size=2][/size]this doesnt work… what can I do?

hello, did you created any method "update()" in your MyModel class?

if NO?

then use the save() method that came with the CActiveRecord


myModel=MyModel::model()->find (‘name=:name’,array(’:name’=>‘fire’));









Save is saving the model as it is (with your modification), update expect a list of attributes to update.

The method update() exists.

Actually there is an update() method, but it doesn’t perform a validation:

what about saveAttributes(), it can save certain fields only but it also doesn’t do validation

for example

$mymodel= MyModel::model()->find('name=:name', array(':name'=>'fire'));