与关注者|朋友用户的自引用关系
为了建立用户之间的关系,创建了一个如下所示的表。
sql
CREATE TABLE `friends`(
`from` INT NOT NULL,
`to` INT NOT NULL,
UNIQUE INDEX(`from`, `to`)
);
您可能知道 - 字段 from
和 to
是 users
表中 user_id
的键。
我正在使用 Kohana 3.09 及其默认模块 Auth。
问题是...
*如何围绕用户与(默认)Model_User 类的关系创建 ORM 功能?*
是否需要创建额外的类,或者我可能在关系 one_to_many trouth 和 Many_to_many trouth 方面遇到一些错误,因为它不起作用。 请帮忙。 我致以最诚挚的问候。
To make relationship between users was created a table that looks like.
sql
CREATE TABLE `friends`(
`from` INT NOT NULL,
`to` INT NOT NULL,
UNIQUE INDEX(`from`, `to`)
);
As you may know - field from
and to
is a keys of user_id
from users
table.
I'm using Kohana 3.09 with its default module Auth.
Question is...
*How to make ORM functionality around relations of users with (default) Model_User class?*
Is there any needle to create additional class or perhaps i had some mistakes with relations one_to_many trouth and many_to_many trouth cause it did not work.
Please help.
My best regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该查看文档的这一部分:
http://kohanaframework.org/guide/orm/relationships #hasmany
您的用户类中需要类似的内容
这些选项用于源代码中的这一部分。
You should check out this section of the documentation:
http://kohanaframework.org/guide/orm/relationships#hasmany
You'll need something like this within your user class
These options are used at this part in the source code.