Hi Yii Forum
I am new to Yii. I had a big table with many fields. Now I want to add a new field to that table. Can I know how to add a field without crud generation.
Thanks in advance.
Hi Yii Forum
I am new to Yii. I had a big table with many fields. Now I want to add a new field to that table. Can I know how to add a field without crud generation.
Thanks in advance.
Hi Datta Sai Krishna, welcome to the forum.
[s]
Is this what you want?
http://www.yiiframework.com/doc/api/1.1/CDbCommand#addColumn-detail
[/s]
[EDIT]
I’m sorry. I didn’t understand your question.
Where should I write this code. In the model or _view of the table
Do what CRUD did.
At the top of file add the field
/**
* This is the model class for table "XCalendar".
*
* The followings are the available columns in table 'XCalendar':
* @property integer $ccalid
* @property string $myfield <---ADD HERE
*
* The followings are the available model relations:
* @property Events $evets
*/
Then go to rules(), add its rules. Add it to attributeLabels() and if it add a relation to relations. And finally if searchable, add to search function too.
I am getting the error model.field not declared
Did you even bother to apply my solution?
Well, I didn’t understand your question.
So, this is what I think is decent solution.
Manually add a column to the database table.
Make sure the db schema cache is cleared.
Use Gii’s model generator … but just preview the result and modify your model file manually. Then you will not loose your existing code.
Use Gii’s CRUD generator … but just preview the result and modify your files manually.
After all, you have to do what Stefano is suggesting.
Got it… Thank You Softark and Stefano…