diff --git a/ci/application/config/config.php b/ci/application/config/config.php index 3efe38d..45c8d4f 100644 --- a/ci/application/config/config.php +++ b/ci/application/config/config.php @@ -23,7 +23,7 @@ defined('BASEPATH') OR exit('No direct script access allowed'); | a PHP script and you can easily do that on your own. | */ -$config['base_url'] = '/~brigitte/SAEWEB2.2/ci/'; +$config['base_url'] = '/~gallego/SAEWEB2.2/ci/'; /* |-------------------------------------------------------------------------- diff --git a/ci/application/controllers/Artistes.php b/ci/application/controllers/Artistes.php index 50e7a22..9d5f1f5 100644 --- a/ci/application/controllers/Artistes.php +++ b/ci/application/controllers/Artistes.php @@ -9,8 +9,9 @@ class artistes extends CI_Controller { } public function index(){ $artistes = $this->model_music->getArtists(); + $playlists = $this->model_music->getPlaylist(); $this->load->view('layout/header'); - $this->load->view('artistes_list',['artistes'=>$artistes]); + $this->load->view('artistes_list',['artistes'=>$artistes, 'playlists' => $playlists]); $this->load->view('layout/footer'); } @@ -32,4 +33,12 @@ class artistes extends CI_Controller { redirect('playlist'); } -} \ No newline at end of file + public function addSongOfArtistToPlaylist(){ + $playlistId = $this->input->post('playlist'); + $artistId = $this->input->post('artistId'); + $this->model_music->addAllSongsOfArtistInPlaylist($artistId, $playlistId); + redirect('artistes'); + + } + +} diff --git a/ci/application/models/Model_music.php b/ci/application/models/Model_music.php index a40d57d..b71d35a 100644 --- a/ci/application/models/Model_music.php +++ b/ci/application/models/Model_music.php @@ -107,4 +107,25 @@ class Model_music extends CI_Model { ); } + public function addAllSongsOfArtistInPlaylist($artistId, $playlistId){ + // Récupérer toutes les chansons de l'artiste spécifié + $query = $this->db->query( + "SELECT song.name + FROM song, track, album + WHERE song.id = track.songId + AND track.albumId = album.id + AND album.artistId = ?", + array($artistId) + ); + + $songs = $query->result(); + + // Ajouter chaque chanson dans la playlist spécifiée + foreach ($songs as $song) { + $this->db->query( + "INSERT INTO SongPlaylist (id, name) VALUES (?, ?)", + array($playlistId, $song->name) + ); + } + } } diff --git a/ci/application/views/artistes_list.php b/ci/application/views/artistes_list.php index 7322341..fbbb2f8 100644 --- a/ci/application/views/artistes_list.php +++ b/ci/application/views/artistes_list.php @@ -1,14 +1,17 @@ -
"; - //echo "
"; - echo anchor("artistes/view/{$artiste->id}","{$artiste->name}"); - echo "
"; - echo "
"; - //echo "
{$artistes->year} - {$artistes->artistName}
- //
"; + echo "
"; + echo anchor("artistes/view/{$artiste->id}", "{$artiste->name}"); + echo ""; + echo ""; // Utilisez l'identifiant de l'artiste ici + echo ""; + echo "
"; + echo "
"; } ?> -
\ No newline at end of file +