如何在 Doctrine 中设置默认类型、排序规则和字符集数据库?
如果我使用 Doctrine 1.2 for Symfony 1.4 构建模式,我必须添加选项:类型、整理和字符集,例如:
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
如何设置默认选项(类型、整理、字符集)?我不想每次都这样写。
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 time this write.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只需在 schema.yml 文件的顶部声明它们,它们就会应用于每个表:
来源:http://www.symfony-project.org/doctrine/1_2/en/04-Schema-Files#chapter_04_global_schema_information
Just declare them at the top of the schema.yml file and they will be applied to every table:
Source: http://www.symfony-project.org/doctrine/1_2/en/04-Schema-Files#chapter_04_global_schema_information
我同意汤姆的解决方案。
另一个选项是 - 如果你希望 InnoDB 全局使用(例如也用于插件) - 在您的
ProjectConfiguration.php
中定义它: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
: