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


PHP Category::tableName方法代码示例

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


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

示例1: search

 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ArticleSearch::find();
     $query->joinWith(['category']);
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $dataProvider->sort->attributes['category_title'] = ['asc' => [Category::tableName() . '.title' => SORT_ASC], 'desc' => [Category::tableName() . '.title' => SORT_DESC]];
     $query->andFilterWhere(['id' => $this->id, Article::tableName() . '.is_active' => $this->is_active, 'is_comment_enabled' => $this->is_comment_enabled, 'category_id' => $this->category_id, 'timestamp' => $this->timestamp]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', Category::tableName() . '.title', $this->category_title])->andFilterWhere(['like', 'html_title', $this->html_title])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'key_words', $this->key_words]);
     return $dataProvider;
 }
开发者ID:amarchenkov,项目名称:myCMS,代码行数:21,代码来源:ArticleSearch.php

示例2: actionIndex

 /**
  * Все
  *
  * @param null $q
  * @param null $id
  * @return array
  */
 public function actionIndex($q = null, $id = null)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $out = ['results' => ['id' => '', 'text' => '']];
     if (!is_null($q)) {
         $query = new Query();
         $query->select('id, name')->from(Category::tableName())->where(['like', 'name', $q])->andWhere(['status' => Category::STATUS_ACTIVE])->limit(20);
         $command = $query->createCommand();
         $data = $command->queryAll();
         $categories = [];
         foreach ($data as &$category) {
             $categories[] = ['id' => $category['id'], 'text' => $category['name']];
         }
         $out['results'] = $categories;
     } else {
         if ($id > 0) {
             $category = Category::findById($id, Category::STATUS_ACTIVE);
             if ($category) {
                 $out['results'] = ['id' => $category->id, 'text' => $category->name];
             }
         }
     }
     return $out;
 }
开发者ID:nepster-web,项目名称:yii2-test-job,代码行数:31,代码来源:CategoryController.php

示例3: status

 /**
  * @param int $state
  * @return $this
  */
 public function status($state = Category::STATUS_ACTIVE)
 {
     $this->andWhere([Category::tableName() . '.status' => $state]);
     return $this;
 }
开发者ID:nepster-web,项目名称:yii2-test-job,代码行数:9,代码来源:CategoryQuery.php


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