因此,有类别和产品,我需要选择不是为了打造的产品类别菜单为空的类别。 不为空意味着该类别包含产品或包含产品的后代类别。我想用范围来做,但我似乎无法走得更远。与相关模型或后代只选择模型具有相关车型
东西有点像下面,但我需要递归查询更多水平下降的类别层次
/**
* This is the model class for table "shopCategories".
*
* The followings are the available columns in table 'shop_categories':
* @property integer $id
* @property integer $parentId
* @property integer $order
* @property integer $isActive
* @property integer $cstamp
* @property integer $mstamp
*
* The followings are the available model relations:
* @property ProductCategory $parent
* @property ProductCategory[] $children
* @property ProductCategoryL10n[] $l10n
* @property ProductCategoriesProducts[] $productsJunction
*/
class ProductCategory extends BogoActiveRecord
{
...
public function nonEmpty()
{
$this->getDbCriteria()->mergeWith(array(
'with' => array(
'children',
'children.products'=>array(
'condition'=>'products.isActive=1',
'joinType'=>'INNER JOIN', 'limit'=>1
),
),
));
return $this;
}
...
}
问题在哪里? – 2012-04-18 11:44:17
框架下的抽象,你不能“看到”如果你不熟悉的警予SQL问题我想 – dimvic 2012-04-18 12:00:15