0
在类模型中,getAll方法用于返回所有类别数据。在下面的方法$ roots中的第一个活动记录具有所有根类别和$类别具有根类别的后代类别。如何添加这两个类别。以下是GETALL方法:添加两个模型类
public function getAll()
{
$roots = Category::model()->roots()->findAll();
foreach($roots as $root)
{
$category = Category::model()->findByPk($root->root);
$categories = $category->descendants()->findAll();
}
return $category + $categories; // this does not concatenate, causes error
}