本文整理汇总了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;
}
示例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;
}
示例3: status
/**
* @param int $state
* @return $this
*/
public function status($state = Category::STATUS_ACTIVE)
{
$this->andWhere([Category::tableName() . '.status' => $state]);
return $this;
}