Doctrine ArrayCollection in a human readable format
I'm persisting a field of type ArrayCollection to a MySQL database which contains only stings. The database field is of
type=array in the ORM definition and of type
TEXT in the database.
/** * @var ArrayCollection * * @ORM\Column(name="currencies", type="array") */ private $currencies;
When persisted the field looks like this in the database:
There is a way to get a json array into the database. Just use
type=json_array instead of
type=array in your field definition. That way the result looks more readable:
['EUR', 'USD', 'GBP']
If you want a simple list without the JSON you can also use
type=simple_array and expect the following result:
Just make sure, that you don't have content which contains a
, as this is used as delimiter.