當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Category::findAll方法代碼示例

本文整理匯總了PHP中common\models\Category::findAll方法的典型用法代碼示例。如果您正苦於以下問題:PHP Category::findAll方法的具體用法?PHP Category::findAll怎麽用?PHP Category::findAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在common\models\Category的用法示例。


在下文中一共展示了Category::findAll方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: actionRenderpage

 public function actionRenderpage($url)
 {
     $category = Category::findOne(['link' => $url]);
     if (empty($category)) {
         return $this->run('site/error');
     }
     $subcategories = Category::findAll(['parent' => $category->id]);
     $posts = Post::findAll(['category' => $category->id]);
     return $this->render('category', ['category' => $category, 'subcategories' => $subcategories, 'postsCount' => sizeof($posts), 'posts' => $posts, 'premiumPosts' => \common\models\Post::find()->where(['>', 'premium', date('d-m-Y H:i:s')])->andWhere(['category' => $category->id])->all()]);
 }
開發者ID:BoBRoID,項目名稱:plochadka,代碼行數:10,代碼來源:SiteController.php

示例2: actionCreate

 public function actionCreate()
 {
     $model = new Category();
     if (isset($_POST['sbm_create_category'])) {
         $model->load($_POST);
         //отправляем массив на парсинг
         var_dump($model);
         die;
         //$model->save();
     } else {
         $model = Category::findAll("where parent_id is NULL");
         //выбор коневых категорий
         $this->render('create', ['model' => $model]);
     }
 }
開發者ID:kunaksergey,項目名稱:shop,代碼行數:15,代碼來源:CategoryController.php

示例3: getProductByCategory

 public static function getProductByCategory($category_id, $limit = 6)
 {
     $category = new Category();
     $product = new Product();
     $categoriesData = $category->findAll(['parent_id' => $category_id]);
     $categoryIDs = [];
     if ($categoriesData) {
         foreach ($categoriesData as $categoryData) {
             $categoryIDs[] = $categoryData->id;
         }
         $products = $product->find()->where(['status' => 10, 'is_featured' => 10])->andWhere(['in', 'category_id', $categoryIDs])->limit($limit)->all();
     } else {
         $products = $product->find()->where(['status' => 10, 'is_front' => 10, 'category_id' => $category_id])->limit($limit)->all();
     }
     return $products;
 }
開發者ID:nguyentuansieu,項目名稱:phutungoto,代碼行數:16,代碼來源:FrontendController.php

示例4: actionCatalog

 public function actionCatalog($id = null)
 {
     if ($id) {
         $categories = Category::findAll(['parent_id' => $id]);
         if ($categories === NULL) {
             throw new NotFoundHttpException("Категория {$id} не найдена");
         }
         $oneLevelCategory = Category::findOne(['id' => $id]);
         $this->getView()->title = "Mexanika 74 - Каталог техники: " . $oneLevelCategory->name . " - " . \common\components\Htmlhelper::getMetaList($categories);
         return $this->render('catalog', ['categories' => $categories, 'oneLevelCategory' => $oneLevelCategory]);
     } else {
         //получить разделы у "Каталог техники"
         $partions = Category::getPartions(Category::TECHNICS_ID);
         //получить все категории, входящие в разделы
         $oneLvl = Category::getFirstLevel(Category::TECHNICS_ID);
         $this->getView()->title = "Mexanika 74 - Каталог техники: " . \common\components\Htmlhelper::getMetaList($partions);
         return $this->render('catalog', ['categories' => $oneLvl, 'parents' => $partions]);
     }
 }
開發者ID:phpsong,項目名稱:ExtJS5-Yii2,代碼行數:19,代碼來源:SiteController.php

示例5: run

 public function run()
 {
     parent::run();
     // TODO: Change the autogenerated stub
     $category = new Category();
     $product = new Product();
     $parent_category = $category->findOne(['id' => $this->category_id]);
     $categoriesData = $category->findAll(['parent_id' => $this->category_id]);
     $category_slug = $parent_category->slug;
     $categoryIDs = [];
     if ($categoriesData) {
         foreach ($categoriesData as $categoryData) {
             $categoryIDs[] = $categoryData->id;
         }
         $products = $product->find()->where(['status' => 10, 'is_featured' => 10])->andWhere(['in', 'category_id', $categoryIDs])->limit($this->limit)->all();
     } else {
         $products = $product->find()->where(['status' => 10, 'is_front' => 10, 'category_id' => $this->category_id])->limit($this->limit)->all();
     }
     return $this->render('widget/front_product', ['nodes' => $products, 'category_slug' => $category_slug]);
 }
開發者ID:nguyentuansieu,項目名稱:phutungoto,代碼行數:20,代碼來源:FrontProductWidget.php

示例6: actionIndex

 public function actionIndex()
 {
     $model = Category::findAll("where parent_id is NULL");
     //выбор коневых категорий
     $this->render('index', ['model' => $model]);
 }
開發者ID:kunaksergey,項目名稱:shop,代碼行數:6,代碼來源:SiteController.php


注:本文中的common\models\Category::findAll方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。