Public Function Actionindex ($id) {$this->pagetitle = yii::t (' zh_cn ', ' page_title_product '); $current _product_category_model = Productcategory::model ()->findbypk ($id); $criteria = new Cdbcriteria (); $criteria->limit = 5; $product _category = Productcategory::model ()->findall ($criteria); $product _sub_category = Productsubcategory::model ()->findall (' product_category_id=:p roduct_category_id ', array (':p roduct_category_id ' = $id)); $products = Product::model ()->findall (' product_status= "online" and product_category_id=:p roduct_category_id ', Array (':p roduct_category_id ' = $id)); $this->render ("index", Array ("Products" and "$products", "current_product_category_model" = $current _product_category_model, "product_category" and "_category", "Product_sub_category" $product = $product _sub_category,)); }
$criteria->order = ' id desc '; I know, but I can only sort the $product_category, and I want to sort out the $products. Thank you.
Reply content:
Public Function Actionindex ($id) {$this->pagetitle = yii::t (' zh_cn ', ' page_title_product '); $current _product_category_model = Productcategory::model ()->findbypk ($id); $criteria = new Cdbcriteria (); $criteria->limit = 5; $product _category = Productcategory::model ()->findall ($criteria); $product _sub_category = Productsubcategory::model ()->findall (' product_category_id=:p roduct_category_id ', array (':p roduct_category_id ' = $id)); $products = Product::model ()->findall (' product_status= "online" and product_category_id=:p roduct_category_id ', Array (':p roduct_category_id ' = $id)); $this->render ("index", Array ("Products" and "$products", "current_product_category_model" = $current _product_category_model, "product_category" and "_category", "Product_sub_category" $product = $product _sub_category,)); }
$criteria->order = ' id desc '; I know, but I can only sort the $product_category, and I want to sort out the $products. Thank you.
Elder brother, you will be the $product_category
sort of, then you put the $product_category
sort of code to the $products
top not to O?
$products = Product::model()->findAll(new CDbCriteria(array( "condition" => 'product_status="online" AND product_category_id=:product_category_id', "order" => "id desc", "params" => array(':product_category_id' => $id) )));