Имею таблицу category вида:
id|parent|title
И метод relations:
Код: Выделить всё
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(
'parentModel'=>array(self::BELONGS_TO,'Category','parent'),
'children'=>array(self::HAS_MANY,'Category','id','condition'=>'??.parent=category.id','alias'=>'B'),
);
}
Вариант вида:
Код: Выделить всё
'children'=>array(self::HAS_MANY,'Category','id','condition'=>'??.parent=id','alias'=>'B'),