Friday, December 16, 2011

Yii loop through Parent Model's Id


$categoryModel = Category::model();
$categoryData = $categoryModel->findAll( array('order'=>'category_name',     
      'condition'=>'super_category_id=:supcatid', 
      'params'=>array(':supcatid'=>$mySuperCategoryId)
));


foreach($categoryData as $categoryDataValue)

echo $categoryDataValue->category_id;
$productModel = Product::model();
$productData = $productModel->findAll( array('order'=>'product_name', 
      'condition'=>'product_category_id=:catid', 
      'params'=>array(':catid'=>$categoryDataValue->category_id)
));
}//end of foreach

No comments:

Post a Comment

About

Blogger templates