sukkad
sukkad

Reputation: 137

Kohana 3.x ORM has_many through delete relationship

I Have three tables, contact, list and listmembers. Contacts from contact table are associated to lists from list table via listmembers table.

class Model_Contact extends ORM{
        protected $_has_many = array(
                'lists'=>array('model'=>'List', 'through'=>'listmembers', 'far_key'=>'dlid', 'foreign_key'=>'uid')
        );
}

class Model_List extends ORM
{

        protected $_has_many = array(
                'contacts'=>array('model'=>'Contact', 'through'=>'listmembers', 'far_key'=>'uid', 'foreign_key'=>'dlid')
        );
}

I have to update contact and list relationship in listmemebers table - create new relationship between existing contact and existing list - Remove relationship between contact and list How can I achieve this in Kohana ORM? I can always create model for listmembers and directly add/delete on this model. But is there a way to handle via relationship without creating listmembers model?

Upvotes: 0

Views: 844

Answers (1)

matino
matino

Reputation: 17735

I think the documentation explains it quite well: http://kohanaframework.org/3.2/guide/orm/relationships#hasmany-through

Upvotes: 1

Related Questions