开发者

Kohana HABTM self join

开发者 https://www.devze.com 2022-12-22 13:42 出处:网络
I have a problem with using the ORM and creating a has and belongs to many self join using Kohana 2.3.4

I have a problem with using the ORM and creating a has and belongs to many self join using Kohana 2.3.4

I have this table

Tasks

ID | Title | etc......

I need to be able to link tasks to other tasks, a task can have multiple children, and multiple parents. So I was thinking of having this table.

Tasks_Tasks

ID | task_1_id | task_2_id

To link the tasks to each other, but I can't work out in Kohana how to set the foreign keys correctly for the relationships, 开发者_如何学编程or if it is possible at all?

Can anyone suggest an answer? Or even better, a better solution?


Instead of extending ORM you should be extending ORM_Tree. This is built for just this type of relationship. Take a look at system/libraries/ORM_Tree.php.

0

精彩评论

暂无评论...
验证码 换一张
取 消