Using th native MySQL ENUM type in Symfony 1.4 and Doctrine

To use the native MySQL ENUM type in Symfony and Doctrine you will have to update your "project/config/databases.yml" and add the "use_native_enum" directive under "attributes" i.e:
      attributes:        
         use_native_enum: true
         use_dql_callbacks: true
         default_table_collate: utf8_general_ci
         default_table_charset: utf8

Full Version
all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=mydb_prod'
      username: root
      password: 12345
      attributes:                  
         use_native_enum: true
         use_dql_callbacks: true
         default_table_collate: utf8_general_ci
         default_table_charset: utf8
prod:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost'
      username: root
      password: 12345
dev:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=mydb_dev'
      username: root
      password: 12345
test:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn: 'mysql:host=localhost;dbname=mydb_test'
      username: root
      password: 12345

Now clean the Symfony cache and rebuild your project.
symfony cc
symfony doctrine:build --all

Find more about it in http://www.symfony-project.org/reference/1_4/en/07-Databases

Share this