Magento 2 how to increase text type field length?
-
15-04-2021 - |
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!
La solution
try this
$installer->getConnection()->addColumn(
$installer->getTable('sales_order'),
'req_desc',
[
'type' => 'text',
'2M',
'nullable' => true,
'comment' => 'Pakke Shipment Label',
]
);
Autres conseils
$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
Licencié sous: CC-BY-SA avec attribution
Non affilié à magento.stackexchange