ajout chansons
This commit is contained in:
19
CodeIgniter-3.1.13/application/controllers/Chansons.php
Normal file
19
CodeIgniter-3.1.13/application/controllers/Chansons.php
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||||
|
|
||||||
|
class Chansons extends CI_Controller {
|
||||||
|
|
||||||
|
public function __construct(){
|
||||||
|
parent::__construct();
|
||||||
|
$this->load->model('model_music');
|
||||||
|
$this->load->helper('html');
|
||||||
|
$this->load->helper('url');
|
||||||
|
}
|
||||||
|
public function index(){
|
||||||
|
$chansons = $this->model_music->getChansons();
|
||||||
|
$this->load->view('layout/header');
|
||||||
|
$this->load->view('chansons_list',['chansons'=>$chansons]);
|
||||||
|
$this->load->view('layout/footer');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -27,4 +27,18 @@ class Model_music extends CI_Model {
|
|||||||
);
|
);
|
||||||
return $query->result();
|
return $query->result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getChansons(){
|
||||||
|
$query = $this->db->query(
|
||||||
|
"SELECT song.name,song.id,album.year,album.name as albumName, artist.name as artistName, genre.name as genreName
|
||||||
|
FROM song
|
||||||
|
JOIN track ON track.songId = song.id
|
||||||
|
JOIN album ON album.id = track.albumId
|
||||||
|
JOIN artist ON album.artistid = artist.id
|
||||||
|
JOIN genre ON genre.id = album.genreid
|
||||||
|
ORDER BY album.year
|
||||||
|
"
|
||||||
|
);
|
||||||
|
return $query->result();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
CodeIgniter-3.1.13/application/views/chansons_list.php
Normal file
15
CodeIgniter-3.1.13/application/views/chansons_list.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<h5>Chansons list</h5>
|
||||||
|
<section class="list">
|
||||||
|
<?php
|
||||||
|
foreach($chansons as $chansons){
|
||||||
|
echo "<div><article>";
|
||||||
|
echo "<header class='short-text'>";
|
||||||
|
echo anchor("albums/view/{$chansons->id}","{$chansons->name}");
|
||||||
|
echo "</header>";
|
||||||
|
echo "<nav class='short-text'>Nom album: {$chansons->albumName}</nav>";
|
||||||
|
echo "<nav class='short-text'>Genre: {$chansons->genreName}</nav>";
|
||||||
|
echo "<footer class='short-text'>{$chansons->year} - {$chansons->artistName}</footer>
|
||||||
|
</article></div>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</section>
|
||||||
@@ -20,6 +20,7 @@
|
|||||||
<ul>
|
<ul>
|
||||||
<li><?=anchor('albums','Albums');?></li>
|
<li><?=anchor('albums','Albums');?></li>
|
||||||
<li><?=anchor('artistes','Artistes');?></li>
|
<li><?=anchor('artistes','Artistes');?></li>
|
||||||
|
<li><?=anchor('chansons','Chansons');?></li>
|
||||||
<li><?=anchor('playlist','Playlist');?></li>
|
<li><?=anchor('playlist','Playlist');?></li>
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|||||||
Reference in New Issue
Block a user