Add a new column in Doctrine 2 in Zend Framework

拈花ヽ惹草 提交于 2021-02-08 09:28:20

问题


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.

Any help appreciated.


回答1:


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;

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;

and execute this command

doctrine orm:schema-tool:update --force update

for more detail about CLI use this link http://wildlyinaccurate.com/useful-doctrine-2-console-commands



来源:https://stackoverflow.com/questions/18568046/add-a-new-column-in-doctrine-2-in-zend-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!