开发者

how set default type, collation and charset database in Doctrine?

if i build schema with Doctrine 1.2 for Symfony 1.4 i must add options: type, collate and charset, for example:

AlSupplier:
  options:
    type: InnoDB
    collate: utf8_unicode_ci
    charset: utf8
  columns:
    company_name:
      type: string(255)

AlCountry:
  options:
    type: InnoDB
    collate: utf8_unicode_ci
    charset: utf8
  columns:
    country_name:
      type: string(70)

AlSupplierCategory:
  actAs:
    NestedSet:
      hasManyRoots: true
      rootColumnName: root_id
    Searchable:
      fields: [category_keywords]
  options:
    type: InnoDB
    collate: utf8_unicode_ci
    charset: utf8
  columns:
    category_name:
      type: string(200)
    category_description:
      type: text
    category_keywords:
      type: text

how can i set default options (type, collate, charset)? I don't want every开发者_Python百科 time this write.


Just declare them at the top of the schema.yml file and they will be applied to every table:

options:
  type: InnoDB
  collate: utf8_unicode_ci
  charset: utf8

Source: http://www.symfony-project.org/doctrine/1_2/en/04-Schema-Files#chapter_04_global_schema_information


I agree to Tom's solution. Another option would be - if you want InnoDB to be used globally (e.g. also for plugins) - to define it in your ProjectConfiguration.php:

public function configureDoctrineConnection(Doctrine_Connection $connection)
{
  $connection->setAttribute(Doctrine::ATTR_DEFAULT_TABLE_TYPE, 'InnoDB');
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜