API 给出的代码如下:
public function up()
{
$this->addColumn('table_name', 'column_name', 'string', $options);
}
但是没有关于选项数组中可以包含的内容的文档。
http://www.doctrine-project.org/Doctrine_Migration_Base/1_2#method_addcolumn
API 给出的代码如下:
public function up()
{
$this->addColumn('table_name', 'column_name', 'string', $options);
}
但是没有关于选项数组中可以包含的内容的文档。
http://www.doctrine-project.org/Doctrine_Migration_Base/1_2#method_addcolumn
For people coming in: it looks like this is really defined from the Data Access Layer. Here is the list of options for columns from the DBAL docs: http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-representation.html
文档是错误的。查看Doctrine/Migration/base.php,可以看到如下函数原型:
/**
* Add a add column change.
*
* @param string $tableName Name of the table
* @param string $columnName Name of the column
* @param string $type Type of the column
* @param string $length Length of the column
* @param array $options Array of options for the column
* @return void
*/
public function addColumn($tableName, $columnName, $type, $length = null, array $options = array())
因此,要添加长度,请将其作为第四个参数。我暂时忽略了这些选项。
按照顶部的“浏览代码”链接,您可以按照代码到$options['length']
inDoctrine_Migration_Base::column()
和第二个参数 in Doctrine_Migration_Base::_addChange()
。不时查看源代码,它为您提供概述:)