Finalisation des bugs
This commit is contained in:
@@ -100,28 +100,53 @@ class Model_music extends CI_Model {
|
||||
$query = $this->db->query("SELECT * FROM genre");
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
public function searchAlbums($query, $genre){
|
||||
$sql = "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
|
||||
WHERE album.name LIKE ? OR artist.name LIKE ?
|
||||
ORDER BY album.id ASC";
|
||||
|
||||
// Paramètres pour les conditions de recherche
|
||||
$params = ["%{$query}%", "%{$query}%"];
|
||||
|
||||
if (!empty($genre)) {
|
||||
$sql .= " AND genre.id = ?";
|
||||
$params[] = $genre;
|
||||
}
|
||||
|
||||
$query = $this->db->query($sql, $params);
|
||||
|
||||
public function playlistOfUser($id){
|
||||
$user_id = $this->session->userdata('user_id');
|
||||
$this->db->select('id');
|
||||
|
||||
$this->db->from('playlist');
|
||||
$this->db->where('userId', $user_id);
|
||||
$this->db->where('id', $id);
|
||||
|
||||
$query = $this->db->get();
|
||||
|
||||
return $query->num_rows() > 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function searchAlbums($query, $genre) {
|
||||
// Sélection des colonnes
|
||||
$this->db->select('album.name, album.id, year, artist.name as artistName, genre.name as genreName, jpeg');
|
||||
|
||||
// Tables et jointures
|
||||
$this->db->from('album');
|
||||
$this->db->join('artist', 'album.artistid = artist.id');
|
||||
$this->db->join('genre', 'genre.id = album.genreid');
|
||||
$this->db->join('cover', 'cover.id = album.coverid');
|
||||
|
||||
// Conditions de recherche
|
||||
$this->db->group_start();
|
||||
$this->db->like('album.name', $query);
|
||||
$this->db->or_like('artist.name', $query);
|
||||
$this->db->group_end();
|
||||
|
||||
// Condition supplémentaire par genre si spécifié
|
||||
if (!empty($genre)) {
|
||||
$this->db->where('genre.id', $genre);
|
||||
}
|
||||
|
||||
// Tri par défaut
|
||||
$this->db->order_by('album.id', 'ASC');
|
||||
|
||||
// Exécution de la requête
|
||||
$query = $this->db->get();
|
||||
|
||||
// Renvoi des résultats
|
||||
return $query->result();
|
||||
}
|
||||
|
||||
|
||||
public function createPlaylist($name, $userId) {
|
||||
$data = array(
|
||||
|
Reference in New Issue
Block a user