Add column to database from model to controller in yii

534 Views Asked by At

In the Yii MVC,

I've added a column to my database in my model using:

$success = Yii::app()->ft_website_prod->createCommand()->addColumn('ft_website.users', 'columnname', 'varchar(64)');

I now need to know how to get this to execute using the controller. I'm new to Yii so even though i've read as much of the Docs as possible, I still can't figure this out.

1

There are 1 best solutions below

0
On

New column could be added to the table as shown

Yii::app()->db->schema->addColumn( 'table_name', 'column_name', 'column type ' );

And droping column as shown

Yii::app()->db->schema->dropColumn( 'tables_name', 'column_name' );