예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TableOne::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(['id' => $this->id]);
     return $dataProvider;
 }
 public function actionExample()
 {
     $tableOneRecords = TableOne::findOne(1);
     $tableThreeRecords = [tableThree::findOne(2), tableThree::findOne(3)];
     $extraColumns = [];
     // extra columns to be saved to the many to many table
     $unlink = true;
     // unlink tags not in the list
     $delete = true;
     // delete unlinked tags
     $tableOneRecords->linkAll('tableThreeRecords', $tableThreeRecords, $extraColumns, $unlink, $delete);
     $tableOneRecords->save();
     // var_dump($tableOneRecords);
     // exit;
 }
예제 #3
0
 public function getTableOneRecord()
 {
     return $this->hasOne(TableOne::className(), ['id' => 't1_id']);
 }