在Zend Framework的Doctrine 2中添加新列 [英] Add a new column in Doctrine 2 in Zend Framework
问题描述
我有带有准则2的Zend框架脚本.
I have Zend framework script with doctrine 2.
我需要添加一个新列,执行此操作的正确时间顺序是什么,即创建列,更新实体,运行迁移等.
I need to add a new column, what is the correct chronology to go about doing that i.e create column, update entities, run migration etc.
任何帮助表示赞赏.
推荐答案
如果要手动,则在数据库表中创建一列,然后在实体类中指定该列波纹管
If you want manually then create a column in database table and specify that column in you entity class as bellow
/**
* @ORM\Column(type="string") // if column is varchar
*/
protected $title;
如果您已经设置了用于生成实体和数据库模式文件的CLI,则使用
if you have already set a CLI for generate entity and database schema file Then use this
-添加新变量,即实体类中的列名
-- add New variable ie column name in Entity class
/**
* @ORM\Column(type="string") // if column is Varchar
*/
protected $title;
并执行此命令
主义orm:schema-tool:update --force更新
doctrine orm:schema-tool:update --force update
有关CLI的更多详细信息,请使用此链接 http://wildlyinaccurate.com/useful-doctrine-2-console-commands
for more detail about CLI use this link http://wildlyinaccurate.com/useful-doctrine-2-console-commands
这篇关于在Zend Framework的Doctrine 2中添加新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!