本文整理汇总了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()]);
}
示例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]);
}
}
示例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;
}
示例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]);
}
}
示例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]);
}
示例6: actionIndex
public function actionIndex()
{
$model = Category::findAll("where parent_id is NULL");
//выбор коневых категорий
$this->render('index', ['model' => $model]);
}