ferdinandfly
ferdinandfly

Reputation: 371

Symfony2 doctrine reverse engineering, can not generate code one to many

when i tried to use symfony2 doctrine reverse engineering tools, I have a one to many relationship. for example:

A: id, name; B: id, a_id, name   

so the reverse engineering tools give me something like:

class A{  
  private id;
  private name;
}
class B{
  private id, 
  private A a;
  private name;
}   

but what I need is :

class A{
  private id;
  private Bs;
  private name;
}   

How can I make doctrine tools generate this for me ? because the data is changing and I do not want to rewrite every time the database changes.

Upvotes: 1

Views: 1201

Answers (2)

Roel Veldhuizen
Roel Veldhuizen

Reputation: 4723

I am sorry to be the bringer of bad news, but you can't. The only option is to generate the entities and then add the specifics yourself.

http://readthedocs.org/docs/doctrine-orm/en/2.0.x/reference/tools.html#entity-generation

This command is not suited for constant usage. It is a little helper and does not support all the mapping edge cases very well. You still have to put work in your entities after using this command.

Upvotes: 1

Shrujan Shetty
Shrujan Shetty

Reputation: 2392

Perhaps you should go through

http://symfony.com/doc/current/book/doctrine.html

i suggest you change the entity file and then update the database.

Upvotes: 0

Related Questions