Hi Swapna, What Alexandru proposes looks ok :)
And I also suggest you use annotations to begin with, because they're much better documented. You can always switch to yaml later when everything is working correctly. There's even a console command to do this ($ doctrine orm:convert-mapping). -- Jasper N. Brouwer (@jaspernbrouwer) On 30 Mar 2014, at 22:40, Alexandru Pătrănescu <[email protected]> wrote: > To obtain that table structure above entities relations should be organized > this way: > > Role{ > id - integer > name - string > } > > Users{ > id - integer > name - string > role - ManyToOne Role > relatives - OneToMany Relative > } > > Relations{ > id - integer > name - string > } > > Relative{ > id - integer > user - ManyToOne User > relativeuser ManyToOne User > relation ManyToOne Relation > invitedby ManyToOne User > } > > As you see there is no need for a ManyToMany association. > > I guess the model could be improved but it is good for start. For now just be > sure to add 2 Relative objects for a real-life relation, like one brother, > one brother or one father, one son. > > > I think you should be able to create your yaml file by yourself although I > suggest to use annotations instead of yaml. > > Regards, > Alex > > > On Sun, Mar 30, 2014 at 6:45 PM, Swapna V <[email protected]> wrote: >> Hi, >> >> I am new to doctrine world. I have problem with understanding many-to-many >> associations. Following is my table structure: >> >> **users** >> >> id int(11) NOT NULL >> >> name varchar(50) NOT NULL >> >> role_id int(11) NOT NULL >> >> **roles** >> >> int int(11) NOT NULL >> >> role varchar(255) NOT NULL >> >> **relations** >> >> id int(11) NOT NULL >> >> name varchar(50) NOT NULL >> >> **relatives** >> >> id int(11) NOT NULL >> >> user_id int(11) NOT NULL >> >> relativeuser_id int(11) NOT NULL >> >> relation_id int(11) NOT NULL >> >> invitedby_id int(11) NULL >> >> according to above schema relatives columns user_id, relativeuser_id and >> invitedby_id are foreign key from users table. And relation_id is foreign >> key from relations table. >> >> >> Please help me creating associations for this table. (if you give answer in >> yaml format will be helpful). >> >> Thank you, >> >> Swapna V -- You received this message because you are subscribed to the Google Groups "doctrine-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/doctrine-user. For more options, visit https://groups.google.com/d/optout.
