/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Document::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(['DocumentId' => $this->DocumentId, 'TopicId' => $this->TopicId, 'DocumentTypeId' => $this->DocumentTypeId, 'ParentDocumentId' => $this->ParentDocumentId, 'Year' => $this->Year, 'Date' => $this->Date, 'EditionNumber' => $this->EditionNumber, 'DocumentOrder' => $this->DocumentOrder, 'OldId' => $this->OldId, 'IndexId' => $this->IndexId]); $query->andFilterWhere(['like', 'Note', $this->Note])->andFilterWhere(['like', 'Publication', $this->Publication])->andFilterWhere(['like', 'Intro', $this->Intro])->andFilterWhere(['like', 'Summary', $this->Summary])->andFilterWhere(['like', 'Text', $this->Text])->andFilterWhere(['like', 'Title', $this->Title])->andFilterWhere(['like', 'Number', $this->Number])->andFilterWhere(['like', 'HTML', $this->HTML]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getDocuments() { return $this->hasMany(Document::className(), ['user_id' => 'id']); }
/** * @return \yii\db\ActiveQuery */ public function getDocuments() { return $this->hasMany(Document::className(), ['ParentDocumentId' => 'DocumentId']); }
/** * Finds the Document model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Document the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Document::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function actionDocument($id) { $connection = \Yii::$app->db; $data = Document::find()->where("documentid=" . $id)->one(); $sql = $connection->createCommand('SELECT documenttype.name FROM document, documenttype WHERE documenttype.documenttypeid = document.documenttypeid AND document.documentid =' . $id); $documentTypeName = $sql->queryAll(); $documentItem = Documentitem::find()->where("documentid=" . $id)->all(); return $this->render('document', array('document' => $data, 'documentitem' => $documentItem, 'documentTypeName' => $documentTypeName)); }