Revision 67 | Revision 82 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed
<?Class Album{var $id;var $name;var $sampler;var $genre;var $pic;var $year;var $p_del;var $artist;function __construct($id=0){global $db, $prefix;if ($id){$sql="SELECT * FROM $prefix"."albums WHERE a_id=$id";$res=$db->query($sql);$row=$res->fetchRow();$this->id=$id;$this->name=stripslashes($row["a_name"]);$this->sampler=$row["a_sampler"];$this->genre=$row["a_genre"];$this->year=$row["a_year"];$this->pic =stripslashes(($row["a_pic"])?$row["a_pic"]:"nopic.jpg");$this->artist=$row["a_artist"];}else{$this->id=0;$this->name="";$this->sampler=0;$this->genre=-1;$this->pic="";$this->year=0;$this->artist=0;}return $this;}function Album($id=0){$this->__construct($id);}function update($a_name, $a_pic, $a_year, $a_sampler=0, $a_genre=0, $p_del=0, $a_artist=0){$this->name=$a_name;$this->sampler=$a_sampler;$this->year=$a_year;$this->pic=$a_pic;$this->genre=$a_genre;$this->p_del=$p_del;$this->artist=$a_artist;}function save($mode="save"){global $db, $prefix;switch ($mode){case "save":$sql="INSERT INTO $prefix"."albums (a_name, a_sampler, a_pic, a_year, a_genre, a_artist) VALUES ('$this->name', $this->sampler, '$this->pic', $this->year, $this->genre, $this->artist)";break;case "update":$pic_sql="";if ($this->pic || $this->p_del){$pic_sql="a_pic='$this->pic',";}$sql="UPDATE $prefix"."albums SET a_name='$this->name', a_sampler=$this->sampler, ".$pic_sql." a_year=$this->year, a_genre=$this->genre, a_artist=$this->artist WHERE a_id=$this->id";break;case "del":break;}return $db->query($sql);}function Liste($start=0,$anz=0){global $db, $prefix, $common;$sql="SELECT * FROM $prefix"."albums";if ($anz > 0){$res=$db->limitquery($sql,$start,$anz);$id=0;$ret=array(array());while ($row=$res->fetchRow()){$ret[$id]["link_id"]=$row["a_id"];$ret[$id]["a_name"]=stripslashes($row["a_name"]);$ret[$id]["a_year"]=($row["a_year"])?$row["a_year"]:$common["unknown"];$ret[$id]["a_pic"]=stripslashes(($row["a_pic"])?$row["a_pic"]:"nopic.jpg");$ret[$id]["a_type"]=($row["a_sampler"])?$common["yes"]:$common["no"];$artist=new Artist($row["a_artist"]);if($row["a_artist"]==1){$ret[$id]["a_artist"]=$common["$artist->name"];}else{$ret[$id]["a_artist"]=($artist->fname)?"$artist->fname $artist->name":"$artist->name";}$g=new Genre($row["a_genre"]);$ret[$id]["a_genre"]=$g->name;$id++;}return $ret;}else{$res=$db->query($sql);return $res->numRows();}}function getAlbums(){global $db, $prefix, $common;$sql="SELECT * FROM $prefix"."albums ORDER BY a_name";$res=$db->query($sql);$ret["-1"]=$common["please_select"];while ($row=$res->fetchRow()){$id=$row["a_id"];$ret[$id]=stripslashes($row["a_name"]);}return $ret;}}?>