update model from db

I added an atribute to db.How to update model with this new attribute?

This is what I would do

[list=1]

[*]delete db schema chaches in protected/runtime/cache

[*]run model generator of gii

[*]preview the modified model code and cut and paste what should be changed

[/list]

The 3rd process can be different. You may totally overwrite the existing code if you don’t mind loosing all the changes that you have made before.

Or, if the changes are trivial, you may manually edit the code, not using gii.

Any way, you should clear the db schema cache when you have made changes to the db schema.

you delete the code inside modelcode.php?

I mean, you can run gii to update your model codes in your "protected/models" directory.

I don’t delete any code. I just delete “db schema caches” in “protected/runtime/cache”.

You must not touch any codes under the "framework" directory.

but i dont have that cache directory under protected/runtime. just gii-1.1.10 and the file application.log

Oh, I’m sorry.

If you haven’t configured the app to enable the db schema cache, then you don’t have to worry about it.

But I recommend you to read the following.

http://www.yiiframework.com/doc/guide/1.1/en/topics.performance#using-caching-techniques

http://www.yiiframework.com/doc/api/1.1/CDbConnection#schemaCachingDuration-detail

On version 1.1.10 is not necessary delete db schema caches -in fact, my FTP doesn’t let me delete those files because I’m not authorized-. Yii updates the db schema caches.

I changed my DB and in Gii I updated the model but without rewrite my model’s file, because I have made lots of changes on model’s file and the change in DB was small, so added this little change in my model’s file’s code. All went fine doing in this way.