public function newsongAction() { $request = $this->getRequest(); if ($request->isPost()) { $album_id = $request->getParam('album_id'); $title = $request->getParam('title'); $price = $request->getParam('price'); $duration = $request->getParam('duration'); $description = $request->getParam('description'); $genres = $request->getParam('genres'); $artist_ids = $request->getParam('ids'); $data = array('album_id' => $album_id, 'title' => $title, 'price' => $price, 'duration' => $duration, 'description' => $description); $song_model = new Application_Model_Song(); $id = $song_model->insert($data); $genre_array = split("\n", $genres); foreach ($genre_array as $genre) { $db = Zend_Registry::get('db'); $sql = "INSERT INTO song_genre (song_id, genre) VALUES ('{$id}', '{$genre}');"; $db->query($sql); } $artist_array = split("\n", $artist_ids); foreach ($artist_array as $artist) { $db = Zend_Registry::get('db'); $sql = "INSERT INTO song_artist (song_id, artist_id, role) VALUES ('{$id}', '{$artist}', 'Singer');"; $db->query($sql); } $_SESSION['success'] = true; $_SESSION['message'] = "Song added to DB successfully."; } }
public function userAction() { $user_model = new Application_Model_User(); $users = $user_model->fetchAll(); $this->view->users = $users; $review_model = new Application_Model_Review(); $reviews = $review_model->fetchAll(); $this->view->reviews = $reviews; $song_model = new Application_Model_Song(); $songs = $song_model->fetchAll(); $this->view->songs = $songs; }