【问题标题】:MediumBlob in Laravel database schemaLaravel 数据库模式中的 MediumBlob
【发布时间】:2013-12-04 01:47:13
【问题描述】:

如何在 Laravel 架构构建器中创建 Mediumblob

在文档中它说:

$table->binary('data'); // BLOB equivalent to the table

但我需要一个 MediumBlob,否则图像会在 64K 时被截断;我们正在运行 MySQL。

我知道 Laravel 的架构构建器与数据库无关,但有没有办法避免“原生方式”,如果没有,我该如何创建 Mediumblob 列?

【问题讨论】:

    标签: mysql database laravel laravel-4


    【解决方案1】:

    你不能。

    issue 建议使用原始查询来创建此类列,因此您应该在迁移文件中执行以下操作:

    Schema::create("<table name>", function($table) {
        // here you do all columns supported by the schema builder
    });
    
    // once the table is created use a raw query to ALTER it and add the MEDIUMBLOB
    DB::statement("ALTER TABLE <table name> ADD <column name> MEDIUMBLOB");
    

    【讨论】:

    • 您是否创建了问题?你的号码?我能找到它
    • user2629998 链接到问题
    【解决方案2】:

    字段已创建,但无法插入文件。并导致以下错误:

    #1118 - Row size too large (&gt; 8126)

    将某些列更改为 TEXT 或 BLOB 或使用 ROW_FORMAT=DYNAMICROW_FORMAT=COMPRESSED 可能会有所帮助。在当前行格式中,768 字节的 BLOB 前缀是内联存储的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-08-20
      • 2021-11-08
      • 1970-01-01
      • 1970-01-01
      • 2018-06-04
      • 1970-01-01
      相关资源
      最近更新 更多