adding new property to model

so i am kind of new in yii

i try to playing around

so what i tried to do is to add more column to the table after crud

so for example my table is(id,username,password) -> crud

and now i want to add email to the table so i added it(id,username,password,email)

so now how i make to the table model recognize this Users->email.

i tried to add it to the rules,attributeLabels,search and still no work


sorry for my poor English

edit: i will ask it in different way

what is the step that need to be done to changing the database after crud as done?

Add it to the rules array and you should be fine. If you’ve already done this then paste it here and we’ll have a look.

You have to take care about the schema cache of the db-connection if you have a cache enabled.

The easy way js to just add it as a normal property in your model file.


class Users extends CActiveRecord{

public $email;

//the rest of the code


thank you all

what i done is to declare property like Sampa said

and also add it to the rules like rookie84 said

and it seems to be work

I am new to Yii so I have not had to do this yet, but I always thought that I could make the change to my DB and then use Gii to preview the newly generated version and view it in in my browser and see how it in would change my module without overtiring my code.

So I tried it to see, maybe Gii was preventing this because the file already existed. I was right you can preview updated code in Gii of existing models but what was really smart was that it provides a link to a diff showing the difference between my current model and what a newly generated one would be.

The more I use Yii the more impressed I am, that is very cool.