Many to many relationship

Hello, I have small issue, in the documentation in robots and parts example, relation between these two models is many to many and to implement this relation doc says defining has many relation in in robots model , has many relation in parts model and belongs to relation in robotsparts for both robots and parts models, and then defining many to many relation in robots model.

It's not clear to me, What is the best behavior to implement relation in this case.

Thanks



10.2k
edited Oct '15

I've actually never implemented a many to many in Phalcon, but the idea is you have a table of robots, a table of parts, and a junction table of robot parts that will server as a bridge between the two. Robot 1 has Part 2 and 3 so there would be two rows in robot parts. One row with robot 1 part 2 and one row with robot 1 part 3. From there you build the has many, belongs to, and has many relationships.

Thnaks for your reply,

Ok, I know about what you said, and understood to me, but my question was in this case what is the best behavior to implement, has many and belongs to or has many to many relation, please see phalcon doc about relationships.

Many thanks