0

I have three tables:

  • banners (id, url, img)
  • banner_on_position (banner, position, loading)
  • banner_positions (id, name)

When I run the doctrine:mapping:import, doctrine creates only two tables. Banners and BannerPositions. Auto-generation doesn't create an own entity for the banner_on_position table.

Is there a way to access the loading attribute with querybuilder? OR How to tell doctrine to create own entity?

Until now I had no problems with auto generation of entities and it was very comfortable. I hope I don't have to create to code manually.

rakete
  • 2,953
  • 11
  • 54
  • 108

1 Answers1

0

You have to create code manually in that case. If your many_to_many table have some extra properties then you need to use that trick: Both side need to use oneToMany relation for banner_on_position and banner_on_position need to have manyToOne to both tables.

Check how we did it in similar case (ContainerWidget have link to container, widget and custom parameter - position). https://github.com/superdesk/web-publisher/blob/master/src/SWP/Bundle/TemplateEngineBundle/Resources/config/doctrine/ContainerWidget.orm.yml

Here is also really good question and answers on stackoverflow: Doctrine2: Best way to handle many-to-many with extra columns in reference table

Community
  • 1
  • 1
Paweł Mikołajczuk
  • 3,692
  • 25
  • 32