当前位置: 首页>>代码示例>>PHP>>正文


PHP Category::tableName方法代码示例

本文整理汇总了PHP中app\modules\shop\models\Category::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP Category::tableName方法的具体用法?PHP Category::tableName怎么用?PHP Category::tableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在app\modules\shop\models\Category的用法示例。


在下文中一共展示了Category::tableName方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 /**
  * @return string
  */
 public function run()
 {
     parent::run();
     if (null === $this->rootCategory) {
         return '';
     }
     $cacheKey = $this->className() . ':' . implode('_', [$this->viewFile, $this->rootCategory, null === $this->depth ? 'null' : intval($this->depth), intval($this->includeRoot), intval($this->fetchModels), intval($this->onlyNonEmpty), implode(',', $this->excludedCategories), \Yii::$app->request->url]) . ':' . json_encode($this->additional);
     if (false !== ($cache = \Yii::$app->cache->get($cacheKey))) {
         return $cache;
     }
     /** @var array|Category[] $tree */
     $tree = Category::getMenuItems(intval($this->rootCategory), $this->depth, boolval($this->fetchModels));
     if (true === $this->includeRoot) {
         if (null !== ($_root = Category::findById(intval($this->rootCategory)))) {
             $tree = [['label' => $_root->name, 'url' => Url::toRoute(['@category', 'category_group_id' => $_root->category_group_id, 'last_category_id' => $_root->id]), 'id' => $_root->id, 'model' => $this->fetchModels ? $_root : null, 'items' => $tree]];
         }
     }
     if (true === $this->onlyNonEmpty) {
         $_sq1 = (new Query())->select('main_category_id')->distinct()->from(Product::tableName());
         $_sq2 = (new Query())->select('category_id')->distinct()->from('{{%product_category}}');
         $_query = (new Query())->select('id')->from(Category::tableName())->andWhere(['not in', 'id', $_sq1])->andWhere(['not in', 'id', $_sq2])->all();
         $this->excludedCategories = array_merge($this->excludedCategories, array_column($_query, 'id'));
     }
     $tree = $this->filterTree($tree);
     $cache = $this->render($this->viewFile, ['tree' => $tree, 'fetchModels' => $this->fetchModels, 'additional' => $this->additional, 'activeClass' => $this->activeClass, 'activateParents' => $this->activateParents]);
     \Yii::$app->cache->set($cacheKey, $cache, 0, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Category::className()), ActiveRecordHelper::getCommonTag(Product::className())]]));
     return $cache;
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:31,代码来源:CategoriesList.php

示例2: down

 public function down()
 {
     $this->dropColumn(Category::tableName(), 'date_added');
     $this->dropColumn(Category::tableName(), 'date_modified');
     $this->dropColumn(Product::tableName(), 'date_added');
     $this->dropColumn(Product::tableName(), 'date_modified');
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:7,代码来源:m150923_101638_date_modified.php

示例3: run

 public function run()
 {
     $query = Category::find();
     $query->andWhere([Category::tableName() . '.active' => 1]);
     if ($this->root_category_id !== null) {
         $query->andWhere([Category::tableName() . '.parent_id' => $this->root_category_id]);
     }
     if ($this->category_group_id !== null) {
         $query->andWhere([Category::tableName() . '.category_group_id' => $this->category_group_id]);
     }
     $query->groupBy(Category::tableName() . ".id");
     $query->orderBy($this->sort);
     if ($this->limit !== null) {
         $query->limit($this->limit);
     }
     $object = Object::getForClass(Category::className());
     \app\properties\PropertiesHelper::appendPropertiesFilters($object, $query, $this->values_by_property_id, []);
     $sql = $query->createCommand()->getRawSql();
     $cacheKey = "FilteredCategoriesWidget:" . md5($sql);
     $result = Yii::$app->cache->get($cacheKey);
     if ($result === false) {
         $categories = Category::findBySql($sql)->all();
         $result = $this->render($this->viewFile, ['categories' => $categories]);
         Yii::$app->cache->set($cacheKey, $result, 86400, new \yii\caching\TagDependency(['tags' => ActiveRecordHelper::getCommonTag(Category::tableName())]));
     }
     return $result;
 }
开发者ID:yii2ApplicationCollect,项目名称:dotplant2,代码行数:27,代码来源:FilteredCategoriesWidget.php

示例4: up

 public function up()
 {
     $this->addColumn(Page::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
     $this->addColumn(Product::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
     $this->addColumn(Category::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
     $this->addColumn(PrefilteredPages::tableName(), 'mate_keywords', $this->string()->defaultValue(null));
 }
开发者ID:HannibalLecktor,项目名称:dotplant2,代码行数:7,代码来源:m160107_092054_add_meta_keywords_1.php

示例5: filteredProducts

 /**
  * Returns products for special filtration query
  * Used in ProductsWidget and ProductController
  *
  * @param $category_group_id
  * @param array $values_by_property_id
  * @param null|integer|string $selected_category_id
  * @param bool|string $force_sorting If false - use UserPreferences, if string - use supplied orderBy condition
  * @param null|integer $limit limit query results
  * @param bool $apply_filterquery Should we apply filter query(filters based on query params ie. price_min/max)
  * @param bool $force_limit False to use Pagination, true to use $limit and ignore pagination
  * @param array $additional_filters Array of callables that will apply additional filters to query
  */
 public static function filteredProducts($category_group_id, array $values_by_property_id = [], $selected_category_id = null, $force_sorting = false, $limit = null, $apply_filterquery = true, $force_limit = false, array $additional_filters = [])
 {
     Yii::beginProfile("FilteredProducts");
     if (null === ($object = Object::getForClass(static::className()))) {
         throw new \yii\web\ServerErrorHttpException('Object not found.');
     }
     /** @var \app\modules\shop\ShopModule $module */
     $module = Yii::$app->getModule('shop');
     $onlyParents = $module->filterOnlyByParentProduct;
     $query = static::find()->with('images');
     if (true === $onlyParents) {
         $query->andWhere([static::tableName() . '.parent_id' => 0, static::tableName() . '.active' => 1]);
     } else {
         $query->andWhere(['!=', static::tableName() . '.parent_id', 0]);
         $query->andWhere([static::tableName() . '.active' => 1]);
     }
     if (null !== $selected_category_id) {
         $query->innerJoin($object->categories_table_name . ' ocats', 'ocats.category_id = :catid AND ocats.object_model_id = ' . static::tableName() . '.id', [':catid' => $selected_category_id]);
     } else {
         $query->innerJoin($object->categories_table_name . ' ocats', 'ocats.object_model_id = ' . static::tableName() . '.id');
     }
     $query->innerJoin(Category::tableName() . ' ocatt', 'ocatt.id = ocats.category_id AND ocatt.category_group_id = :gcatid AND ocatt.active = 1', [':gcatid' => $category_group_id]);
     $query->addGroupBy(static::tableName() . ".id");
     $userSelectedSortingId = UserPreferences::preferences()->getAttributes()['productListingSortId'];
     $allSorts = [];
     if ($force_sorting === false) {
         $allSorts = ProductListingSort::enabledSorts();
         if (isset($allSorts[$userSelectedSortingId])) {
             $query->addOrderBy($allSorts[$userSelectedSortingId]['sort_field'] . ' ' . $allSorts[$userSelectedSortingId]['asc_desc']);
         } else {
             $query->addOrderBy(static::tableName() . '.sort_order');
         }
     } elseif (empty($force_sorting) === false || is_array($force_sorting) === true) {
         $query->addOrderBy($force_sorting);
     }
     $productsPerPage = $limit === null ? UserPreferences::preferences()->getAttributes()['productsPerPage'] : $limit;
     \app\properties\PropertiesHelper::appendPropertiesFilters($object, $query, $values_by_property_id, Yii::$app->request->get('p', []));
     // apply additional filters
     $cacheKeyAppend = "";
     if ($apply_filterquery) {
         $query = Yii::$app->filterquery->filter($query, $cacheKeyAppend);
     }
     foreach ($additional_filters as $filter) {
         if (is_callable($filter)) {
             call_user_func_array($filter, [&$query, &$cacheKeyAppend]);
         }
     }
     $cacheKey = 'ProductsCount:' . implode('_', [md5($query->createCommand()->getRawSql()), $limit ? '1' : '0', $force_limit ? '1' : '0', $productsPerPage]) . $cacheKeyAppend;
     $pages = null;
     if ($force_limit === true) {
         $query->limit($limit);
     } else {
         $products_query = clone $query;
         $products_query->limit(null);
         if (false === ($pages = Yii::$app->cache->get($cacheKey))) {
             $pages = new Pagination(['defaultPageSize' => !is_null($query->limit) ? $query->limit : $productsPerPage, 'pageSizeLimit' => [], 'forcePageParam' => false, 'totalCount' => $products_query->count()]);
             Yii::$app->cache->set($cacheKey, $pages, 86400, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Category::className()), ActiveRecordHelper::getCommonTag(static::className()), ActiveRecordHelper::getCommonTag($module->className())]]));
         }
         $query->offset($pages->offset)->limit($pages->limit);
     }
     $cacheKey .= '-' . Yii::$app->request->get('page', 1);
     if (false === ($products = Yii::$app->cache->get($cacheKey))) {
         $products = $query->all();
         Yii::$app->cache->set($cacheKey, $products, 86400, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Category::className()), ActiveRecordHelper::getCommonTag(static::className()), ActiveRecordHelper::getCommonTag($module->className())]]));
     }
     Yii::endProfile("FilteredProducts");
     return ['products' => $products, 'pages' => $pages, 'allSorts' => $allSorts];
 }
开发者ID:Razzwan,项目名称:dotplant2,代码行数:81,代码来源:Product.php

示例6: actionAutocomplete

 public function actionAutocomplete()
 {
     /**
      * @todo Добавить отображение вложенности
      */
     $search = Yii::$app->request->get('search');
     $out = ['more' => false];
     if (!is_null($search['term'])) {
         $query = new Query();
         $query->select('id, name AS text')->from(Category::tableName())->andWhere(['like', 'name', $search['term']])->limit(100);
         $command = $query->createCommand();
         $data = $command->queryAll();
         $out['results'] = array_values($data);
     }
     /* elseif ($id > 0) {
            $out['results'] = ['id' => $id, 'text' => Category::findOne($id)->name];
        } else {
            $out['results'] = ['id' => 0, 'text' => Yii::t('app', 'No matching records found')];
        }*/
     echo Json::encode($out);
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:21,代码来源:BackendCategoryController.php

示例7: down

 public function down()
 {
     $this->dropTable('{{%user_category}}');
     $this->dropTable('{{%user_eav}}');
     $this->dropTable('{{%user_property}}');
     $this->dropTable(UserService::tableName());
     $this->dropTable(User::tableName());
     $this->dropTable('{{%auth_assignment}}');
     $this->dropTable('{{%auth_item_child}}');
     $this->dropTable('{{%auth_item}}');
     $this->dropTable('{{%auth_rule}}');
     $this->dropTable(ErrorUrl::tableName());
     $this->dropTable(ErrorLog::tableName());
     $this->dropTable(Review::tableName());
     $this->dropTable(Notification::tableName());
     $this->dropTable('{{%submission_eav}}');
     $this->dropTable('{{%submission_category}}');
     $this->dropTable('{{%submission_property}}');
     $this->dropTable(Submission::tableName());
     $this->dropTable('{{%form_property}}');
     $this->dropTable('{{%form_eav}}');
     $this->dropTable(Form::tableName());
     $this->dropTable('{{%order_category}}');
     $this->dropTable('{{%order_eav}}');
     $this->dropTable('{{%order_property}}');
     $this->dropTable(PaymentType::tableName());
     $this->dropTable(ShippingOption::tableName());
     $this->dropTable(OrderChat::tableName());
     $this->dropTable(OrderTransaction::tableName());
     $this->dropTable(OrderItem::tableName());
     $this->dropTable(Order::tableName());
     $this->dropTable(SubscribeEmail::tableName());
     $this->dropTable(CategoryGroupRouteTemplates::tableName());
     $this->dropTable('{{%product_category}}');
     $this->dropTable('{{%property_category}}');
     $this->dropTable('{{%category_eav}}');
     $this->dropTable(Category::tableName());
     $this->dropTable(CategoryGroup::tableName());
     $this->dropTable('{{%page_eav}}');
     $this->dropTable('{{%page_category}}');
     $this->dropTable('{{%page_property}}');
     $this->dropTable(Page::tableName());
     $this->dropTable(ViewObject::tableName());
     $this->dropTable(View::tableName());
     $this->dropTable(Layout::tableName());
     $this->dropTable('{{%product_property}}');
     $this->dropTable(Product::tableName());
     $this->dropTable(Property::tableName());
     $this->dropTable(Route::tableName());
     $this->dropTable('{{%product_eav}}');
     $this->dropTable('{{%product_static_value_full_slug}}');
     $this->dropTable('{{%product_category_full_slug}}');
     $this->dropTable(PropertyStaticValues::tableName());
     $this->dropTable(PropertyHandler::tableName());
     $this->dropTable(PropertyGroup::tableName());
     $this->dropTable(ObjectStaticValues::tableName());
     $this->dropTable(ObjectPropertyGroup::tableName());
     $this->dropTable(Object::tableName());
     $this->dropTable(DynamicContent::tableName());
     $this->dropTable(Navigation::tableName());
     $this->dropTable(Image::tableName());
     $this->dropTable('{{%session}}');
     $this->dropTable(ApiService::tableName());
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:64,代码来源:m141023_084857_init.php

示例8: up

 public function up()
 {
     mb_internal_encoding(Yii::$app->getModule('core')->internalEncoding);
     $data = (include __DIR__ . DIRECTORY_SEPARATOR . 'demo-data.php');
     $productObject = Object::getForClass(Product::className());
     /** @var PropertyHandler $handler */
     $handler = PropertyHandler::findOne(['handler_class_name' => 'app\\properties\\handlers\\text\\TextProperty']);
     if (!is_null($handler)) {
         $this->textHandlerId = $handler->id;
     }
     $handler = PropertyHandler::findOne(['handler_class_name' => 'app\\properties\\handlers\\select\\SelectProperty']);
     if (!is_null($handler)) {
         $this->selectHandlerId = $handler->id;
     }
     $this->insert(PropertyGroup::tableName(), ['object_id' => $productObject->id, 'name' => 'Общая группа свойств']);
     $commonGroupId = $this->db->lastInsertID;
     $this->insert(Property::tableName(), ['property_group_id' => $commonGroupId, 'name' => 'Производитель', 'key' => 'vendor', 'property_handler_id' => $this->selectHandlerId, 'handler_additional_params' => '{}', 'has_static_values' => 1, 'has_slugs_in_values' => 1]);
     $this->properties['vendor'] = $this->db->lastInsertID;
     $staticProperties = ['Тип крепления бура', 'Макс. энергия удара', 'Количество скоростей работы', 'Питание', 'Тип процессора', 'Тип памяти', 'Частота памяти: 1600 МГц', 'Количество слотов памяти', 'Максимальный размер памяти', 'Размер экрана: 15.6 "', 'Тип экрана', 'Тип видеоадаптера'];
     foreach ($data as $category) {
         $this->insert(Category::tableName(), ['category_group_id' => 1, 'parent_id' => 1, 'name' => $category['name'], 'h1' => $category['name'], 'title' => $category['name'] . ' с доставкой в любой город России и СНГ', 'breadcrumbs_label' => $category['name'], 'slug' => Helper::createSlug($category['name']), 'announce' => $category['content'], 'content' => $category['content']]);
         $categoryId = $this->db->lastInsertID;
         $this->insert(PropertyGroup::tableName(), ['object_id' => $productObject->id, 'name' => $category['name']]);
         $groupId = $this->db->lastInsertID;
         foreach ($category['products'] as $product) {
             // product
             $slug = Helper::createSlug($product['name']);
             if (isset($this->products[$slug])) {
                 $slug = mb_substr($slug, 0, 66) . '-' . uniqid();
             }
             $this->insert(Product::tableName(), ['parent_id' => 0, 'measure_id' => 1, 'currency_id' => 1, 'sku' => $product['id'], 'main_category_id' => $categoryId, 'name' => $product['name'], 'title' => $product['name'], 'breadcrumbs_label' => $product['name'], 'h1' => $product['name'], 'slug' => $slug, 'announce' => Helper::trimPlain($product['description']), 'content' => $product['description'], 'price' => $product['prices']['min'], 'old_price' => $product['prices']['max']]);
             $productId = $this->db->lastInsertID;
             $this->products[$slug] = $productId;
             // categories
             $this->batchInsert('{{%product_category}}', ['category_id', 'object_model_id'], [[1, $productId], [$categoryId, $productId]]);
             // property groups
             $this->batchInsert(ObjectPropertyGroup::tableName(), ['object_id', 'object_model_id', 'property_group_id'], [[$productObject->id, $productId, $commonGroupId], [$productObject->id, $productId, $groupId]]);
             // properties
             if (isset($product['vendor'])) {
                 $this->saveStatic($productId, 'vendor', $product['vendor']);
             }
             foreach ($product['details']['modelDetails'] as $group) {
                 foreach ($group['params'] as $property) {
                     $property['name'] = trim($property['name'], '/ ');
                     if (in_array($property['name'], $staticProperties)) {
                         $key = $this->getKey($property['name']);
                         if (!isset($this->properties[$key])) {
                             $this->insert(Property::tableName(), ['property_group_id' => $groupId, 'name' => $property['name'], 'key' => $key, 'property_handler_id' => $this->selectHandlerId, 'handler_additional_params' => '{}', 'has_static_values' => 1, 'has_slugs_in_values' => 1]);
                             $this->properties[$key] = $this->db->lastInsertID;
                         }
                         $this->saveStatic($productId, $this->getKey($property['name']), str_replace($property['name'] . ': ', '', $property['value']));
                     } else {
                         $this->saveEav($productId, $groupId, $property['name'], str_replace($property['name'] . ': ', '', $property['value']));
                     }
                 }
             }
             // images
             $prodPhotos = [];
             if (isset($product['photos'])) {
                 foreach ($product['photos'] as $photo) {
                     $prodPhotos[] = [$productObject->id, $productId, $photo['name'], $product['name'], $product['name']];
                 }
             }
             if (isset($product['mainPhoto']['name'])) {
                 $prodPhotos[] = [$productObject->id, $productId, $product['mainPhoto']['name'], $product['name'], $product['name']];
             }
             if (count($prodPhotos) > 0) {
                 $this->batchInsert(Image::tableName(), ['object_id', 'object_model_id', 'filename', 'image_alt', 'image_title'], $prodPhotos);
             }
         }
     }
     srand();
     $cdnNumber = rand(1, 2);
     $imgUrl = "http://static-{$cdnNumber}.dotplant.ru/demo-photos.zip";
     $imagesPath = Yii::getAlias('@webroot/files/');
     $imgsFile = $imagesPath . DIRECTORY_SEPARATOR . 'imgs.zip';
     if (file_exists($imgsFile) === false) {
         $fp = fopen($imgsFile, 'w+');
         $ch = curl_init($imgUrl);
         curl_setopt($ch, CURLOPT_TIMEOUT, 600);
         curl_setopt($ch, CURLOPT_FILE, $fp);
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
         curl_exec($ch);
         curl_close($ch);
         fclose($fp);
     }
     if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
         echo "\n\nWow! You are running windows! Please unzip {$imgsFile} to {$imagesPath} \n\n";
     } else {
         passthru('/usr/bin/env unzip -n "' . $imgsFile . '" -d "' . $imagesPath . '"');
     }
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:92,代码来源:m150605_094805_demo_data.php

示例9: down

 public function down()
 {
     $this->addColumn(Product::tableName(), 'is_deleted', 'TINYINT UNSIGNED DEFAULT \'0\'');
     $this->addColumn(Page::tableName(), 'is_deleted', 'TINYINT UNSIGNED DEFAULT \'0\'');
     $this->addColumn(Category::tableName(), 'is_deleted', 'TINYINT UNSIGNED DEFAULT \'0\'');
 }
开发者ID:tqsq2005,项目名称:dotplant2,代码行数:6,代码来源:m150422_105109_hard_deleting.php


注:本文中的app\modules\shop\models\Category::tableName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。