public function actionDel($mid, $song) { $musicModel = Music::model(); if ($musicModel->deleteByPk($mid)) { if (unlink('uploads/' . $song)) { $this->redirect(array('index')); } } }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. */ public function loadModel() { if ($this->_model === null) { if (isset($_GET['id'])) { $this->_model = Music::model()->findbyPk($_GET['id']); } if ($this->_model === null) { throw new CHttpException(404, '您请求的页面不存在。'); } } return $this->_model; }
public function run() { #if($this->_model===null) if ($this->getController()->_model === null) { if (isset($_GET['id'])) { $this->getController()->_model = Music::model()->findbyPk($_GET['id']); } if ($this->getController()->_model == null) { throw new CHttpException(404, '您请求的页面不存在。'); } } echo chr(239) . chr(187) . chr(191) . $this->getController()->_model->lyric; }
public function common() { $common = array(); //选择音乐 $sql = "SELECT song,singer,special FROM {{music}} WHERE sel=1"; $common['music'] = Music::model()->findAllBySql($sql); //音乐学则结束 $sql = "SELECT cname,cid FROM {{category}} LIMIT 10"; $common['nav'] = Category::model()->findAllBySql($sql); $sql = "SELECT title,aid FROM {{article}} WHERE type=1 ORDER BY time DESC LIMIT 7 "; $common['hot'] = $this->findAllBySql($sql); $sql = "SELECT title,aid FROM {{article}} ORDER BY time DESC LIMIT 7 "; $common['new'] = $this->findAllBySql($sql); return $common; }
public function run() { header("Cache-Control: no-cache, must-revalidate"); header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); if (isset($_GET['id'])) { $code = chr(239) . chr(187) . chr(191) . "<list>\n"; $code .= "<m opened=\"1\" label=\"播放列表\">\n"; $ids = explode("_", trim($_GET['id'])); foreach ($ids as $id) { $this->getController()->_model = Music::model()->findbyPk($id); $url = rawurlencode($this->getController()->_model->url); $url = preg_replace(array('/%3A/i', '/%2F/i', '/%3D/i', '/%27/i', '/%22/i', '/%2A/i'), array(':', '/', '=', '\'', '+'), $url); $siteUrl = 'http://' . $_SERVER['HTTP_HOST'] . Yii::app()->urlManager->baseUrl; $code .= "\t<m type=\"\" src=\"{$url}\" lrc=\"{$siteUrl}?r=music/lrc&id={$this->getController()->_model->id}\" label=\"{$this->getController()->_model->name}-{$this->getController()->_model->artist->name}\" />\n"; } $code .= "</m>\n"; $code .= "</list>"; echo $code; } if ($this->getController()->_model == null) { throw new CHttpException(404, '您请求的页面不存在。'); } }
protected function afterFind() { parent::afterFind(); $this->_tags = $this->_oldTags = ItemsTags::returnTagsString(ItemsTags::MUSIC_TYPE, $this->id); Music::model()->updateCounters(array('click' => 1), 'id=:id', array(':id' => $this->id)); }