public function loadModel($id) { $model = SongText::findOne($id); if ($model === null) { throw new \yii\web\HttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Для выбора и прослушивания музыки * @return string */ function actionMusic() { if ($user = Yii::$app->getRequest()->getQueryParam('user')) { if (!$user) { return 'Доступ запрещен!'; } if (Yii::$app->getRequest()->getQueryParam('theme_song')) { $theme = Yii::$app->getRequest()->getQueryParam('theme_song'); $arr_theme = explode(',', Yii::$app->getRequest()->getQueryParam('theme_song')); if (!empty($arr_theme)) { $this->songs = []; } foreach ($arr_theme as $theme) { $query = new Query(); $songs_ids = $query->from('songtexts')->match($theme)->all(); foreach ($songs_ids as $arr_item_rec) { foreach ($arr_item_rec as $id) { $this->songs[] = SongText::findOne((int) $id); } } } //return var_dump($arr); return $this->renderPartial('songs', ['songs' => $this->songs]); //else return $this->renderPartial('songs', ['song' => SongText::findOne(2)]); } $songs = []; $query = new Query(); $songs_ids = $query->from('songtexts')->match('new year')->all(); foreach ($songs_ids as $arr_item_rec) { foreach ($arr_item_rec as $id) { $songs[] = SongText::findOne((int) $id); } } return $this->renderPartial('songs', ['songs' => $songs]); } }
/** * Для обрезки ссылки в базе песен */ function actionSongTextCutLink() { for ($i = 25; $i <= 6069; $i++) { if (SongText::findOne($i) && SongText::findOne($i)->link != null) { $song = SongText::findOne($i); $song->link = substr(SongText::findOne($i)->link, 48); //echo $song->link.PHP_EOL; $song->update(false); echo $i . PHP_EOL; } } }