Domanda

I would like to import existing tables from database into Symfony project (realise them as entities). I used commands:

php app/console doctrine:mapping:import --force BundleName yml
php app/console doctrine:mapping:convert annotation ./src
php app/console doctrine:generate:entities BundleName

The commands worked fine and the problem is that any "join" table (foreign keys in place) will be missing, e.g. If I have table Order, Item and OrderItem, where OrderItem contains the mapping of Order and Item, then Symfony/Doctrine resolves Order and Item into a many to many relation and creates entities for Order and Item only.

Question is how can I make doctrine to import the "join" table as well and resolve it into two many to one relations with respect to the target tables.

È stato utile?

Soluzione

Doctrine won't be able to guess the relations exactly. It have even seen imports fail because some tables did not contain primary keys. One to many / many to many relations are defined by the way it is used and enforced by constraints.

The import is a run-once facility. You will have to check and update the mapping yourself afterwards.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top