简体   繁体   English

PHP Doctrine 1.2表名

[英]PHP Doctrine 1.2 table names

I'm trying to upgrade my doctrine ORM from 1.1.6 to 1.2.1 but i've enountered a BC issue with table names. 我正在尝试将我的理论ORM从1.1.6升级到1.2.1,但是我已经用表名开始了BC问题。

Some of my table names have several words (eg t_foo_bar for class FooBar) where the t_ prefix is generated automatically with: 我的一些表名包含几个单词(例如,用于FooBar的t_foo_bar),其中t_前缀是使用以下命令自动生成的:

$manager->setAttribute(Doctrine_Core::ATTR_TBLNAME_FORMAT, 't_%s');

This worked well in previous versions. 这在以前的版本中效果很好。 In 1.2.1 however, it looks like doctrine is looking for t_foobar (instead of t_foo_bar with an underscore). 但是在1.2.1中,主义似乎正在寻找t_foobar(而不是带下划线的t_foo_bar)。

Do you know how to solve this without changing the table names? 您知道如何在不更改表名称的情况下解决此问题吗?

In the setTableDefinition() method of your model you can call $this->setTableName('t_foo_bar') to set the table name explicitly. 在模型的setTableDefinition()方法中,可以调用$this->setTableName('t_foo_bar')来显式设置表名。 This is much better, as if some class gets renamed, the app will continue to work. 这样好得多,就好像某个类被重命名了一样,该应用程序将继续运行。

Oh, I've got here through google. 哦,我通过Google到了这里。 I've just started symfony and want to add symfony+doctrine app to an existing web-app. 我刚刚开始使用symfony,并想将symfony + doctrine应用程序添加到现有的Web应用程序中。

I've found this stuff in the Doctrine docs (notice second line): 我已经在《 Doctrine》文档中找到了这些东西(注意第二行):


Group:
  **tableName: group_table**
  columns:
    id:
      type: integer(4)
      autoincrement: true
      primary: true
    name:
      type: string(255)
  relations:
    Users:
      foreignAlias: Groups
      class: User
      refClass: GroupUser

Seems you can define table name in the yml file too. 似乎您也可以在yml文件中定义表名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM