vaujdui v2
This commit is contained in:
@@ -109,7 +109,7 @@ class Model_playlist extends CI_Model {
|
||||
$this->db->insert('playlists', $data);
|
||||
$playlistId = $this->db->insert_id();
|
||||
|
||||
// Filtrage des chansons par genre
|
||||
// Filtrage des chansons par genre et sélection aléatoire
|
||||
$this->db->select('track.id');
|
||||
$this->db->from('track');
|
||||
$this->db->join('song', 'track.songid = song.id');
|
||||
@@ -120,17 +120,13 @@ class Model_playlist extends CI_Model {
|
||||
$this->db->where('genre.name', $genre);
|
||||
}
|
||||
|
||||
$this->db->order_by('RAND()');
|
||||
$this->db->limit($numSongs);
|
||||
|
||||
$query = $this->db->get();
|
||||
$songs = $query->result();
|
||||
|
||||
if ($numSongs > count($songs)) {
|
||||
$numSongs = count($songs);
|
||||
}
|
||||
|
||||
// Sélection aléatoire de chansons
|
||||
$randomKeys = array_rand($songs, $numSongs);
|
||||
foreach ($randomKeys as $key) {
|
||||
$song = $songs[$key];
|
||||
foreach ($songs as $song) {
|
||||
$this->addItem($playlistId, $song->id, 'song');
|
||||
}
|
||||
|
||||
|
@@ -14,6 +14,12 @@ class User_model extends CI_Model {
|
||||
public function create_user($data) {
|
||||
return $this->db->insert('user', $data);
|
||||
}
|
||||
|
||||
public function emailExists($email) {
|
||||
$this->db->where('email', $email);
|
||||
$query = $this->db->get('user');
|
||||
return $query->num_rows() > 0;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user