Sunday, September 18, 2011

Deal with MySQL types natively unsupported by Doctrine2

Some types of data, specific to MySQL are not supported by Doctrine2 when generating the mapping and entities from an existing database (reverse engineering).

Nevertheless, there remains the possibility to easily convert them into basic types. Example with ENUM, VARBINARY and TINYBLOB types.

Everything goes in app/config.yml, in the "doctrine" section (only conf, very convenient), see the "mapping_types" attribute :
# Doctrine Configuration doctrine: dbal: default_connection: default connections: default: driver: %database_driver% host: %database_host% port: %database_port% dbname: %database_name% user: %database_user% password: %database_password% charset: UTF8 mapping_types: enum: string varbinary: string tinyblob: text connection1: ... orm: auto_generate_proxy_classes: %kernel.debug% auto_mapping: true

No comments :

Post a Comment

Comments are moderated before being published.