Beispiel #1
0
 public static function getAuthors($id = null)
 {
     $authors = array();
     foreach (BooksAuthors::find()->all() as $data) {
         $authors[$data->id] = $data->fio;
     }
     return empty($id) ? $authors : $authors[$id];
 }
 public static function getAuthorsName($authors = null, $html = false)
 {
     $returnArray = array();
     $returnHtml = '';
     foreach (BooksAuthors::find()->where(!empty($authors) ? 'id in (' . $authors . ')' : '')->all() as $data) {
         $returnArray[$data->id] = $data->fio;
         $returnHtml .= $data->fio . '<BR>';
     }
     return !$html ? $returnArray : $returnHtml;
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BooksAuthors::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, 'created_at' => $this->created_at]);
     $query->andFilterWhere(['like', 'fio', $this->fio]);
     return $dataProvider;
 }