Kohana Uno a Muchos 1:n

FILE (/application/classes/model/company/company.php)

class Model_Company_Company extends ORM {
    protected $_table_name = 'company';    
   
    protected $_belongs_to = array(
        'rsCategory' => array(
            'model' => 'company_category',
            'foreign_key' => 'category_id',
        )    
    );
   
}

FILE (/application/classes/model/company/category.php)

class Model_Company_Category extends ORM {
   
    protected $_table_name = 'category';  
   
    protected $_has_many = array(            
        'lsCompany' => array(
            'model' => 'company_company',
            'foreign_key' => 'category_id',
        )
    );
}
post-author