2024-05-21 15:05:29 +02:00
|
|
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
|
|
class Model_music extends CI_Model {
|
|
|
|
public function __construct(){
|
|
|
|
$this->load->database();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getAlbums(){
|
|
|
|
$query = $this->db->query(
|
|
|
|
"SELECT album.name,album.id,year,artist.name as artistName, genre.name as genreName,jpeg
|
|
|
|
FROM album
|
|
|
|
JOIN artist ON album.artistid = artist.id
|
|
|
|
JOIN genre ON genre.id = album.genreid
|
|
|
|
JOIN cover ON cover.id = album.coverid
|
|
|
|
ORDER BY year
|
|
|
|
"
|
|
|
|
);
|
|
|
|
return $query->result();
|
|
|
|
}
|
2024-05-23 11:41:06 +02:00
|
|
|
|
|
|
|
public function getArtists(){
|
|
|
|
$query = $this->db->query(
|
|
|
|
"SELECT artist.id, artist.name
|
|
|
|
FROM artist
|
|
|
|
Group by artist.id
|
|
|
|
"
|
|
|
|
);
|
|
|
|
return $query->result();
|
|
|
|
}
|
2024-05-27 13:08:39 +02:00
|
|
|
|
2024-05-30 16:14:38 +02:00
|
|
|
public function getPlaylist(){
|
|
|
|
$query = $this->db->query(
|
|
|
|
"SELECT playlist.id, playlist.name
|
|
|
|
FROM playlist
|
|
|
|
Group by playlist.id
|
|
|
|
"
|
|
|
|
);
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
2024-06-03 16:10:43 +02:00
|
|
|
public function deletePlaylist($playlist_id){
|
2024-06-03 17:52:42 +02:00
|
|
|
$this->db->query(
|
|
|
|
"DELETE FROM SongPlaylist WHERE id = ?", array($playlist_id)
|
|
|
|
);
|
|
|
|
|
|
|
|
// Ensuite, supprimer l'enregistrement dans playlist
|
|
|
|
$this->db->query(
|
|
|
|
"DELETE FROM playlist WHERE id = ?", array($playlist_id)
|
|
|
|
);
|
2024-06-03 15:02:52 +02:00
|
|
|
}
|
|
|
|
|
2024-06-05 17:38:12 +02:00
|
|
|
public function delete_Song($playlist_id,$Song_name){
|
|
|
|
$this->db->query(
|
|
|
|
"DELETE FROM SongPlaylist Where id = ? AND name LIKE ?",
|
|
|
|
array($playlist_id, $Song_name)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-06-03 18:44:18 +02:00
|
|
|
public function createPlaylist($name_playlist){
|
|
|
|
$name_playlist_escaped = $this->db->escape($name_playlist);
|
|
|
|
$query = $this->db->query(
|
2024-06-03 19:02:08 +02:00
|
|
|
"INSERT INTO playlist (name) VALUES ($name_playlist_escaped);
|
2024-06-03 18:44:18 +02:00
|
|
|
"
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2024-06-03 15:02:52 +02:00
|
|
|
public function getSongOfPlaylist($playlist_id){
|
|
|
|
$query = $this->db->query(
|
|
|
|
"SELECT SongPlaylist.name
|
|
|
|
FROM SongPlaylist
|
|
|
|
WHERE $playlist_id = SongPlaylist.id;
|
|
|
|
|
|
|
|
"
|
|
|
|
);
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
2024-05-27 14:04:46 +02:00
|
|
|
public function getSongOfAlbum($album_id){
|
|
|
|
$query = $this->db->query(
|
|
|
|
"SELECT song.id, song.name
|
|
|
|
FROM song
|
|
|
|
INNER JOIN track ON song.id = track.songId
|
|
|
|
WHERE track.albumId = ?",
|
|
|
|
array($album_id)
|
2024-05-28 11:34:30 +02:00
|
|
|
);
|
2024-05-27 14:04:46 +02:00
|
|
|
return $query->result();
|
2024-05-27 13:08:39 +02:00
|
|
|
}
|
2024-05-28 11:34:30 +02:00
|
|
|
|
|
|
|
public function getAlbumsOfArtist($artist_id){
|
|
|
|
$query = $this->db->query(
|
|
|
|
"SELECT album.name, album.id, album.year, genre.name as genreName, cover.jpeg
|
|
|
|
FROM album
|
|
|
|
JOIN artist ON album.artistId = artist.id
|
|
|
|
JOIN genre ON album.genreId = genre.id
|
|
|
|
JOIN cover ON album.coverId = cover.id
|
|
|
|
WHERE artist.id = ?",
|
|
|
|
array($artist_id)
|
|
|
|
);
|
|
|
|
return $query->result();
|
|
|
|
}
|
|
|
|
|
2024-05-21 15:05:29 +02:00
|
|
|
}
|