Doctrine ORM - Prefixing Tables

纵然是瞬间 提交于 2019-12-08 02:15:17

问题


I'm using Doctrine 1.2, and would like to know how I can achieve mysql table prefixes with it.

So for instance I would like for our system to be deployed twice on the same database, the first the tables can be prefixed with "one_" and the second can be prefixed with "two_".

Anyone got any idea how to accomplish this? I would imagine it is a config setting but I just can't seem to find it.


回答1:


I haven't tried it but.. from the docs:

$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT, 'one_%s');

Alternatively, you can manually define a table name in your YAML schema:

Foo:
  tableName: one_foo
  columns:
    # etc.

Hope this helps.




回答2:


If you have a UML model of the domain, you can use this UML to Doctrine online service to generate different versions of the corresponding Doctrine script, each one with different prefixes for the tables (choosing a prefix is one of the configuration options you can change as part of the generation process)



来源:https://stackoverflow.com/questions/3853361/doctrine-orm-prefixing-tables

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!