/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Topic::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(['TopicId' => $this->TopicId, 'TopicTypeId' => $this->TopicTypeId, 'ParentTopicId' => $this->ParentTopicId, 'TopicOrder' => $this->TopicOrder, 'OldId' => $this->OldId, 'DocumentCount' => $this->DocumentCount]); $query->andFilterWhere(['like', 'Name', $this->Name]); return $dataProvider; }
public function actionSecondary() { if (isset($_POST['topicId'])) { $topicId = $_POST['topicId']; $returnArray = array(); $data = Topic::find()->where("ParentTopicId=" . $topicId)->all(); foreach ($data as $d) { $arr['name'] = $d['Name']; $arr['topicId'] = $d['TopicId']; array_push($returnArray, $arr); } echo json_encode($returnArray); } }