crea BD playlist + liste des playlists

This commit is contained in:
Wilfried BRIGITTE 2024-05-30 16:14:38 +02:00
parent 83f2697666
commit f1638ed865
7 changed files with 44 additions and 6 deletions

View File

@ -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. | a PHP script and you can easily do that on your own.
| |
*/ */
$config['base_url'] = '/~boutaric/SAEWEB2.2/ci/'; $config['base_url'] = '/~brigitte/SAEWEB2.2/ci/';
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------

View File

@ -18,9 +18,9 @@ class Albums extends CI_Controller {
public function view($album_id){ public function view($album_id){
$songs = $this->model_music->getSongOfAlbum($album_id); $songs = $this->model_music->getSongOfAlbum($album_id);
if (empty($songs)) { if (empty($songs)) {
$songs = []; // Assurez-vous que $songs est un tableau vide si aucune chanson n'est trouvée $songs = [];
} }
// Debugging: Log the $songs variable to see its content
log_message('debug', 'Songs: ' . print_r($songs, true)); log_message('debug', 'Songs: ' . print_r($songs, true));
$this->load->view('layout/header_album'); $this->load->view('layout/header_album');

View File

@ -18,7 +18,7 @@ class artistes extends CI_Controller {
$AlbumsOfArtist = $this->model_music->getAlbumsOfArtist($AlbumsOfArtistId); $AlbumsOfArtist = $this->model_music->getAlbumsOfArtist($AlbumsOfArtistId);
$this->load->view('layout/header_artistes'); $this->load->view('layout/header_artistes');
$this->load->view('albums_artist_list',['AlbumsOfArtist'=>$AlbumsOfArtist]); $this->load->view('albums_artist_list',['AlbumsOfArtist'=>$AlbumsOfArtist]);
$this->load->view('layout/footer'); $this->load->view('layout/footer_artistes');
} }
} }

View File

@ -0,0 +1,17 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Playlist extends CI_Controller {
public function __construct(){
parent::__construct();
$this->load->model('model_music');
}
public function index(){
$playlists = $this->model_music->getPlaylist();
//$this->load->view('layout/header_album');
$this->load->view('playlist_list', ['playlists' => $playlists]);
//$this->load->view('layout/footer_album');
}
}

View File

@ -28,6 +28,16 @@ class Model_music extends CI_Model {
return $query->result(); return $query->result();
} }
public function getPlaylist(){
$query = $this->db->query(
"SELECT playlist.id, playlist.name
FROM playlist
Group by playlist.id
"
);
return $query->result();
}
public function getSongOfAlbum($album_id){ public function getSongOfAlbum($album_id){
$query = $this->db->query( $query = $this->db->query(
"SELECT song.id, song.name "SELECT song.id, song.name

View File

@ -1,10 +1,10 @@
<h5>Artists list</h5> <h5>Artists list</h5>
<section class="list"> <section class="list">
<?php <?php
foreach($artistes as $artistes){ foreach($artistes as $artiste){
//echo "<div><article>"; //echo "<div><article>";
//echo "<header class='short-text'>"; //echo "<header class='short-text'>";
echo anchor("artistes/view/{$artistes->id}","{$artistes->name}"); echo anchor("artistes/view/{$artiste->id}","{$artiste->name}");
echo "<br>"; echo "<br>";
echo "</header>"; echo "</header>";
//echo "<footer class='short-text'>{$artistes->year} - {$artistes->artistName}</footer> //echo "<footer class='short-text'>{$artistes->year} - {$artistes->artistName}</footer>

View File

@ -0,0 +1,11 @@
<h5>Playlist List</h5>
<?php
foreach($playlists as $playlist){
echo "<div><article>";
echo "<header class='short-text'>";
echo anchor("playlists/view/{$playlist->id}","{$playlist->name}");
echo "<br>";
echo "</header>";
echo "</article></div>";
}
?>