views:

502

answers:

2

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.

Some of my table names have several words (e.g. t_foo_bar for class FooBar) where the t_ prefix is generated automatically with:

$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).

Do you know how to solve this without changing the table names?

+1  A: 

In the setTableDefinition() method of your model you can call $this->setTableName('t_foo_bar') to set the table name explicitly. This is much better, as if some class gets renamed, the app will continue to work.

Emil Ivanov
Yeah, that does work without setting the ATTR_TBLNAME_FORMAT attribute, meaning that the name should be set for every table. I did prefer the one line approach although that'll do.Thanks for your prompt response!
Ofir
+1  A: 

Oh, I've got here through google. I've just started symfony and want to add symfony+doctrine app to an existing web-app.

I've found this stuff in the Doctrine docs (notice second line):


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.

TEHEK