Self referencing relation with followers|friends users

后端 未结 1 1663
北恋
北恋 2021-01-16 23:11

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(`         


        
相关标签:
1条回答
  • 2021-01-16 23:59

    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

    protected $_has_many = array(
        'friends' => array(
            'model' => 'user',
            'through' => 'friends',
            'far_key' => 'from',
            'foreign_key' => 'to',
        )
    );
    

    These options are used at this part in the source code.

    0 讨论(0)
提交回复
热议问题