Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relations defined with 'through' are not supported yet #14

Open
cebe opened this issue Mar 13, 2012 · 5 comments
Open

relations defined with 'through' are not supported yet #14

cebe opened this issue Mar 13, 2012 · 5 comments

Comments

@cebe
Copy link
Member

cebe commented Mar 13, 2012

try adding support for it:

http://www.yiiframework.com/doc/guide/1.1/en/database.arr#relational-query-with-through

@tom--
Copy link

tom-- commented Feb 26, 2013

i don't use MANY_MANY, i only use 'through'. if i understand the discussions on yii2 design on the forum, MANY_MANY is on the way out.

@samdark
Copy link
Member

samdark commented Feb 26, 2013

Yes, it is.

@luxcem
Copy link

luxcem commented Jan 20, 2014

I'm developing the support for 'through' relations but I wonder how to pass the data to the behaviour.

eg considering the scheme at http://www.yiiframework.com/doc/guide/1.1/en/database.arr#relational-query-with-through and the scenario in which a group is saved with its users and their roles.

class Group extends CActiveRecord
{
    ...
    public function relations()
    {
        return array(
            'roles'=>array(self::HAS_MANY,'Role','group_id'),
            'users'=>array(
                self::HAS_MANY,'User',array('user_id'=>'id'),'through'=>'roles'
            ),
          ...
        );
    }
}

When Group is saved should it have data in $group->roles or in $group->users

eg :

$this->roles=array( 
    array('user_id' => $user_id1, 'name' => $name1),
    array('user_id' => $user_id2, 'name' => $name2),
    ...
);

// versus :
$this->users=array(
    array('user_id' => $user_id1, 'name' => $name1),
    array('user_id' => $user_id1, 'name' => $name1),
    ...
);

I think that the second option make more sense : in many situations "roles" is just a association table with additional fields.
What we really want to save is the "users" array.

What do you think ? Maybe you have other ideas ?

@motin
Copy link

motin commented Dec 9, 2014

Any news on this? @Arnaud-F Did you finish your development and have anything to share?

@motin
Copy link

motin commented Dec 11, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants