Question

I have a module where I save a PDF file in a text type field, however I just realized that the pdf was not stored completly, it misses some characters. This is how I created the field:

$installer->getConnection()->addColumn(
            $installer->getTable('sales_order'),
            'pakke_label',
            [
                'type' => 'text',
                'nullable' => true,
                'comment' => 'Pakke Shipment Label',
            ]
        );

The pdf has around 120,000 characters, but it's storing more than the half. Is this size increase directly in MySQL? or I can increase the size of the field here in Magento?

Greetings!

Was it helpful?

Solution

try this

$installer->getConnection()->addColumn(
$installer->getTable('sales_order'),
    'req_desc',
    [
        'type' => 'text',
        '2M',
        'nullable' => true,
        'comment' => 'Pakke Shipment Label',
    ]
);

OTHER TIPS

$installer->getConnection()->addColumn(
            $installer->getTable('sales_order'),
            'pakke_label',
            [
                'type' => 'text',
                 100,
                'nullable' => true,
                'comment' => 'Pakke Shipment Label',
            ]
        );

Use your suitable value in place of "100"

Maximum length for MySQL type text,

Type       | Approx. Length     | Exact Max. Length Allowed
-----------------------------------------------------------
TINYTEXT   | 256 Bytes          |           255 characters
TEXT       |  64 Kilobytes      |        65,535 characters
MEDIUMTEXT |  16 Megabytes      |    16,777,215 characters
LONGTEXT   |   4 Gigabytes      | 4,294,967,295 characters
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top