Symfony 1.4 doctrine - 全局数据库表前缀__%s [英] Symfony 1.4 doctrine - global database table prefix__%s
问题描述
我需要设置环境特定的表前缀,所以我发现在ProjectConfiguration :: configureDoctrine(Doctrine_Manager $ manager)中插入不完整的解决方案:
(config / ProjectConfiguration.class.php )
I need to set environment specific table prefixes, so i found unperfect solution in inserting this in ProjectConfiguration::configureDoctrine(Doctrine_Manager $manager): (config/ProjectConfiguration.class.php)
if (sfConfig::get('app_database_table_prefix')) {
$manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT,
sfConfig::get('app_database_table_prefix'));
}
...然后我可以在app.yml中设置env-unique前缀:
... and then i can set env-unique prefixes in app.yml:
prod:
database_table_prefix: prefix__%s
但是,除了插件,所有应用都很酷。
插件忽略config / ProjectConfiguration.class.php。
BUT.. this is cool for all app, except plugins. Plugins ignores config/ProjectConfiguration.class.php.
不知道有关alglobal解决方案没有改变任何插件目录(我需要什么将会影响所有可能的未来应用程序插件)
推荐答案
看起来你正在使用Doctrine,所以看起来像您可以在 databases.yml
文件中设置前缀。这些说明位于此页面的底部,但它看起来像你可以通过将tblname_format添加到databases.yml中的属性来设置表格格式:
It looks like you're using Doctrine, so it looks like you can set the prefix in your databases.yml
file. The instructions are at the bottom of this page, but it looks like you can set the table name format by adding the tblname_format to the attributes in databases.yml like so:
all:
doctrine:
param:
attributes:
tblname_format: YOURPREFIX_%s
这篇关于Symfony 1.4 doctrine - 全局数据库表前缀__%s的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!