eq($id_artiste); if(isset($actif)) $sql .= " AND actif=".($actif ? "1" : "0"); $sql .= " ORDER BY ordre ASC"; $rst = $this->sql->query($sql); while($v_rst = $this->sql->fetch_assoc($rst)) $albums[$v_rst["id"]] = $v_rst; $this->sql->free_result($rst); } catch(Exception $_e) { $albums = false; } return $albums; } /** $max === null : la requete recupere tous les resultats $max === true : la requete recupere $this->env->config("max_list") resultats $max === n : la requete recupere n resultats **/ function albums($start = 0, $max = null, $order_by = null, $order = null, $WHERE = "") { $albums = array(); try { $sql = "SELECT #--albums.*, #--artistes.nom as artiste, #--artistes.id as id_artiste FROM #--albums, #--artistes" ." WHERE #--albums.id_artiste=#--artistes.id" .($WHERE ? " AND ".$WHERE : "") .(isset($order_by) ? " ORDER BY ".$order_by.(isset($order) ? " ".$order: "") : "") .( isset($max) ? ( $max === true ? ($this->env->config("max_list") ? " LIMIT ".$start.",".$this->env->config("max_list") : "") : " LIMIT ".$start.",".$max ) : "" ); $rst = $this->sql->query($sql); while($v_rst = $this->sql->fetch_assoc($rst)) $albums[$v_rst["id"]] = $v_rst; $this->sql->free_result($rst); } catch(Exception $_e) { $albums = false; } return $albums; } function set_artiste_albums($id_artiste, $ordre, $actif) { if(($albums = $this->artiste_albums($id_artiste)) !== false) { try { foreach($albums as $id => $album) { $query = "UPDATE #--albums SET" ." ordre=".$ordre[$id] .", actif=".($actif[$id] ? 1 : 0) ." WHERE id=".$id; $this->sql->query($query); } } catch(Exception $_e) { return false; } } return true; } function artiste_album($id) { $album = array(); try { $sql = "SELECT * FROM #--albums WHERE id=".$this->eq($id); $rst = $this->sql->query($sql); if($v_rst = $this->sql->fetch_assoc($rst)) $album = $v_rst; $this->sql->free_result($rst); } catch(Exception $_e) { $album = false; } return $album; } function add_artiste_album($id_artiste, $titre, $image, $description, $url, $format, $taille, $date_creation) { $id_album; try { $sql = "INSERT INTO #--albums" ."( id_artiste" .", titre" .", image" .", description" .", url" .", format" .", taille" .", date_creation" .", date_publication" .", compteur" .", actif" .") VALUES" ."( ".$this->eq($id_artiste) .", ".$this->eq($titre) .", ".$this->eq($image) .", ".$this->eq($description) .", ".$this->eq($url) .", ".$this->eq($format) .", ".$this->eq($taille) .", ".$this->eq($date_creation) .", NOW()" .", 0" .", 1" .")"; $this->sql->query($sql); $id_album = $this->sql->insert_id(); } catch(Exception $_e) { $id_album = false; } return $id_album; } function set_artiste_album($id, $titre, $image, $description, $url, $format, $taille, $date_creation) { try { $sql = "UPDATE #--albums SET" ." titre=".$this->eq($titre) .", image=".$this->eq($image) .", description=".$this->eq($description) .", url=".$this->eq($url) .", format=".$this->eq($format) .", taille=".$this->eq($taille) .", date_creation=".$this->eq($date_creation) ." WHERE id=".$this->eq($id); $this->sql->query($sql); } catch(Exception $_e) { return false; } return true; } function del_artiste_album($id) { try { $sql = "DELETE FROM #--albums WHERE id=".$this->eq($id); $this->sql->query($sql); } catch(Exception $_e) { return false; } return true; } function inc_album_compteur($id_album) { $url = false; try { $sql = "SELECT url FROM #--albums WHERE id=".$id_album; $rst = $this->sql->query($sql); if($v_rst = $this->sql->fetch_assoc($rst)) $url = $v_rst["url"]; if($url); { $sql = "UPDATE #--albums SET compteur=(compteur + 1) WHERE id=".$id_album; $this->sql->query($sql); } } catch(Exception $_e) { $url = false; } return $url; } } ?>