Doctrine2: How to set all tables to collate with UTF8

前端 未结 14 1022
夕颜
夕颜 2020-12-08 02:55

I am using Doctrine with Symfony2. My config.yml file looks something like this:-

Doctrine Configuration

doctrine:
    dbal:
        driver: %data         


        
14条回答
  •  醉梦人生
    2020-12-08 03:47

    The behavior of collate has changed in doctrine: http://www.doctrine-project.org/jira/browse/DDC-2139

    The collation is now set to utf8_unicode_ci if you don't specify anything at the table level. The way to go right now is to add it to options in your table declaration:

    /**
     * @ORM\Table(options={"collate"="utf8_swedish_ci"})
     * @ORM\Entity
     */
    

    This will generate the correct collation for the table:

    $ php app/console doctrine:schema:update --dump-sql --env=test | grep swedish
    ...  DEFAULT CHARACTER SET utf8 COLLATE utf8_swedish_ci ENGINE = InnoDB;
    

    I've filed an issue for the documentation to be updated to reflect this behaviour.

提交回复
热议问题