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