I appreciate if someone make its its code here is schema
CREATE TABLE IF NOT EXISTS `tbl_category` ( `id` int(10) NOT NULL AUTO_INCREMENT, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
and
CREATE TABLE IF NOT EXISTS `tbl_subcategory` ( `id` int(10) NOT NULL AUTO_INCREMENT, `cid` int(11) NOT NULL, `name` varchar(255) COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY (`id`), FOREIGN KEY (cid) REFERENCES tbl_category(id) ON UPDATE CASCADE ON DELETE CASCADE ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
and here are relations of subcategory
public function relations()
{
// NOTE: you may need to adjust the relation name and the related
// class name for the relations automatically generated below.
return array(
'linkdirectories' => array(self::HAS_MANY, 'Linkdirectory', 'scid'),
'c' => array(self::BELONGS_TO, 'Category', 'cid'),
);
}

Help












