Using ORM Doctrine, I noticed that an array Doctrine generate a longtext field in database. Is there a way to generate text field ?
Thanks
/**
* @var array
*
* @ORM\Column(name="my_field", type="array", nullable=true)
*/
private $myField;
Using ORM Doctrine, I noticed that an array Doctrine generate a longtext field in database. Is there a way to generate text field ?
Thanks
/**
* @var array
*
* @ORM\Column(name="my_field", type="array", nullable=true)
*/
private $myField;
The answer is to define a length for your field, e.g.
Setting length to a value between 256-65535 will give you a TEXT field. The break points are defined in the Doctrine documentation:
http://doctrine-orm.readthedocs.org/projects/doctrine-dbal/en/latest/reference/types.html#id107
Just for the record if anyone stumbles on this question : maximum size and storage requirements of a text field are two very different things.
In MySQL (and I guess other SQL engines), variable-length string types like TEXT or LONGTEXT are stored using a length prefix plus data. The length prefix requires from one to four bytes depending on the data type.
So, basically, the difference between TEXT and LONGTEXT is just the maximum length of the string the field can hold. On disk, it will take the same size (except for two or three bytes)
Source : https://dev.mysql.com/doc/refman/5.1/en/storage-requirements.html