开发者

What are the options for Doctrine's addColumn() migration method?

The API gives the code as:

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

but there's no documentation for what can be included in the o开发者_如何学Cptions array.

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


The documentation is wrong. Looking in Doctrine/Migration/base.php, you can see the following function prototype:

/**
 * 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())

So to add the length, you give it as the 4th parameter. I'm ignoring the options for the moment.


Following the "browse code" link on the top, you can follow the code to $options['length'] in Doctrine_Migration_Base::column() and the second parameter in Doctrine_Migration_Base::_addChange(). Check out the source code from time to time, it gives you an overview :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜