Self Join Using Relationship


I want to implement self join with relationship in yii for single table.actually i have a category table and it contains category(with parent_id=0) and subcategory(with parent_id=category_id) now i want a self join relation which extract the category/subcategory name with its parent category name.and blank as parent name if it do not has any parent.

I read in a forum post(URL: that if i use self::BelongsTo relation then it will create some problem at time of adding a new please give me reply which over come the problem and also steps to follow to do a self join using relationship as i am very new to this relation part of yii.