Doctrine的addColumn()迁移方法有哪些选项?

时间:2010-02-17 20:46:54

标签: php doctrine symfony-1.4

API将代码提供为:

public function up()
{
    $this->addColumn('table_name', 'column_name', 'string', $options);
}

但是没有关于可以包含在选项数组中的内容的文档。

http://www.doctrine-project.org/Doctrine_Migration_Base/1_2#method_addcolumn

3 个答案:

答案 0 :(得分:5)

对于进入的人:看起来这是从数据访问层真正定义的。以下是DBAL文档中列的选项列表:http://docs.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/schema-representation.html

答案 1 :(得分:1)

文档错误。查看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())

因此,要添加长度,请将其作为第4个参数。我暂时忽略了这些选项。

答案 2 :(得分:0)

点击顶部的“浏览代码”链接,您可以按照$options['length']中的Doctrine_Migration_Base::column()Doctrine_Migration_Base::_addChange()中的第二个参数进行操作。不时查看源代码,它给你一个概述:)

相关问题