Symfony - Doctrine: Use a fully UTF8 database

First, edit your config/databases.yml and add :

[yml]

all:
  doctrine:
    class: sfDoctrineDatabase
    param:
      dsn:      mysql:socket=/var/run/mysqld/mysqld.sock;dbname=mydb
      username: mydb
      password: mypassword
      encoding: utf8
      attributes:
        default_table_collate: utf8_unicode_ci
        default_table_charset: utf8

Then open your config/doctrine/schema.yml and add at the top of your file :

|yml]
---
detect_relations: true
options:
  collation: utf8_unicode_ci
  charset: utf8
  type: InnoDB

Of course, if you want to stick to myisam, replace InnoDB by MyIsam.

Befware, some plugins provides their own schema.yml. You may have to modify it, or to inherite it and specify that they're in utf8 (to come later)

Symfony 1.2, 1.3 and 1.4

Haut de page