Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/lib/com/sergids/topmusic/model/GenreDAO.php
<?php
class GenreDAO{
	var $db;
	var $prefix;
	function GenreDAO($db,$prefix="nuke"){
		$this->db=$db;
		$this->prefix=$prefix;
	} 
	function getGenreList($language){
		$sSql="SELECT 
				  ".$this->prefix."_topmusic_genre.idgenre,
				  ".$this->prefix."_topmusic_genre_lang.language,
				  ".$this->prefix."_topmusic_genre_lang.name
				FROM
				  ".$this->prefix."_topmusic_genre
				  INNER JOIN ".$this->prefix."_topmusic_genre_lang ON (".$this->prefix."_topmusic_genre.idgenre = ".$this->prefix."_topmusic_genre_lang.idgenre)
				WHERE
				  ".$this->prefix."_topmusic_genre_lang.language = '".$language."'
				ORDER BY ".$this->prefix."_topmusic_genre_lang.name";
		//echo "sql=".$sSql."<br>";
		$stmt=$this->db->sql_query($sSql);
		$i=0;
		while($rs=$this->db->sql_fetchrow($stmt)){
			$genreList[$rs['idgenre']]=$rs['name'];
		}
		$this->db->sql_freeresult($stmt);
		return $genreList;
	}
	function getActiveGenreList($what,$language){
		switch($what){
			case "albums":
				$table="album";
				break;
			case "songs":
				$table="song";
				break;
			default:
				$table="artist";
		}
		$sSql="SELECT 
				  ".$this->prefix."_topmusic_genre.idgenre,
				  ".$this->prefix."_topmusic_genre_lang.language,
				  ".$this->prefix."_topmusic_genre_lang.name
				FROM
				  ".$this->prefix."_topmusic_genre
				  INNER JOIN ".$this->prefix."_topmusic_genre_lang ON (".$this->prefix."_topmusic_genre.idgenre = ".$this->prefix."_topmusic_genre_lang.idgenre)
				  INNER JOIN ".$this->prefix."_topmusic_".$table." ON (".$this->prefix."_topmusic_genre.idgenre=".$this->prefix."_topmusic_".$table.".idgenre)
				WHERE
				  ".$this->prefix."_topmusic_genre_lang.language = '".$language."' 
				 ORDER BY ".$this->prefix."_topmusic_genre_lang.name";
		//echo "sql=".$sSql."<br>";
		$stmt=$this->db->sql_query($sSql);
		$i=0;
		while($rs=$this->db->sql_fetchrow($stmt)){
			$genreList[$rs['idgenre']]=$rs['name'];
		}
		$this->db->sql_freeresult($stmt);
		return $genreList;
	}
}
?>
Return current item: Top Music module