/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Documenttype::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['DocumentTypeId' => $this->DocumentTypeId, 'TopicTypeId' => $this->TopicTypeId]); $query->andFilterWhere(['like', 'Name', $this->Name])->andFilterWhere(['like', 'Color', $this->Color]); return $dataProvider; }
public function actionComponents($id) { // $documnttypeId = Yii::$app->getRequest()->getQueryParam($id); //echo $id; $documentTypeName = Documenttype::find()->where("documenttypeid=" . $id)->one(); //print_r($documentTypeName); $sql = 'SELECT * FROM topic WHERE topicid IN (SELECT topicid FROM documenttypetopic WHERE documenttypeid = ' . $id . ')'; $data = Topic::findBySql($sql)->all(); // print_r($data); exit; return $this->render('components', array('topic' => $data, 'documentTypeName' => $documentTypeName)); }