Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/shell/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Yii2迁移中如何将数据类型设置为longtext_Yii2_Database Migration - Fatal编程技术网

Yii2迁移中如何将数据类型设置为longtext

Yii2迁移中如何将数据类型设置为longtext,yii2,database-migration,Yii2,Database Migration,我使用以下代码为bodytext获取所需的属性值。数据类型应为longtext()或varchar()。DBMS是MySQL 使用以下代码bodytext将创建为varchar(255)。为什么? $this->createTable('mail_eingang', [ 'id' => $this->primaryKey(), 'mail_adresse_absender' => $this->string(255)->notNull(),

我使用以下代码为
bodytext
获取所需的属性值。数据类型应为
longtext()
varchar()
。DBMS是MySQL

使用以下代码
bodytext
将创建为
varchar(255)
。为什么?

$this->createTable('mail_eingang', [
    'id' => $this->primaryKey(),
    'mail_adresse_absender' => $this->string(255)->notNull(),
    'betreff' => $this->string(255),
    'bodytext' => $this->string(), //this will actually set bodytext to varchar(255). It should be longtext() or varchar() !!
    'gelesen' => $this->smallInteger(1)->notNull()->defaultValue(0),
    'angelegt_am' => $this->datetime(),
    'angelegt_von' => $this->integer(11),
    'aktualisiert_am' => $this->datetime(),
    'aktualisiert_von' => $this->integer(11),
    'FOREIGN KEY ([[angelegt_von]]) REFERENCES person ([[id]]) ON DELETE SET NULL ON UPDATE RESTRICT',
    'FOREIGN KEY ([[aktualisiert_von]]) REFERENCES person ([[id]]) ON DELETE SET NULL ON UPDATE RESTRICT',
], $tableOptions);

如果64 KB足够,您可以使用:

如果您真的需要一个长文本专栏,您应该使用以下内容:

'bodytext' => $this->getDb()->getSchema()->createColumnSchemaBuilder('longtext');
或将类型指定为原始字符串:

'bodytext' => 'LONGTEXT',

好吧干得好,很好。谢谢。因为你的努力,给了你声誉分数!
'bodytext' => 'LONGTEXT',