Dieses Blog durchsuchen

Samstag, 16. Juli 2016

symfony 3 manyToOne Relation / foreignkeys in doctrine2

If you have multiple table related to one table, lets say via a userid you can tell symfony to do the job for you by generating enties for you.

You can also do this by yourself by editing the entities.
this is the database with all the many2one relations 


At next we generate our entityclasses Posts, Replies and User
Have a look on the annotations of the userid in the related classes replies and post. In both cases the userid is tagged like that:
This annotation tells doctrine to relate the userid to the column "id" in the usertable



Keine Kommentare:

Kommentar veröffentlichen