因此,有類別和產品,我需要選擇不是爲了打造的產品類別菜單爲空的類別。 不爲空意味着該類別包含產品或包含產品的後代類別。我想用範圍來做,但我似乎無法走得更遠。與相關模型或後代只選擇模型具有相關車型
東西有點像下面,但我需要遞歸查詢更多水平下降的類別層次
/**
* 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