/** * 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; }
/** * @return \yii\db\ActiveQuery */ public function getTopic() { return $this->hasOne(Topic::className(), ['TopicId' => 'TopicId']); }
/** * @return \yii\db\ActiveQuery */ public function getTopics() { return $this->hasMany(Topic::className(), ['TopicTypeId' => 'TopicTypeId']); }
/** * @return \yii\db\ActiveQuery */ public function getTopics() { return $this->hasMany(Topic::className(), ['TopicId' => 'TopicId'])->viaTable('documenttypetopic', ['DocumentTypeId' => 'DocumentTypeId']); }
/** * Finds the Topic model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Topic the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Topic::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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); } }