0

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!

2 Answers 2

1

try this

$installer->getConnection()->addColumn(
$installer->getTable('sales_order'),
    'req_desc',
    [
        'type' => 'text',
        '2M',
        'nullable' => true,
        'comment' => 'Pakke Shipment Label',
    ]
);
2
$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
1
  • how can I specify the type as long text in Magento ? I think I would need Long text Nov 5, 2020 at 14:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.