当前位置: 首页>>代码示例>>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;未经允许,请勿转载。