Subversion-Projekte lars-tiefland.medien

Revision

Revision 43 | Zur aktuellen Revision | Blame | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

<?
        class Track
        {
                var $id;
                var $t_id;
                var $cd;
                var $artist;
                var $name;
                var $dur;
                var $genre;
                
                function __construct($id)
                {
                        global $db, $prefix;
                        if ($id)
                        {
                                $sql="SELECT * FROM $prefix"."tracks WHERE t_id=$id";
                                $res=$db->query($sql);
                                $row=$res->fetchRow();
                                $this->id=$id;
                                $this->t_id=$row["cd_t_id"];
                                $this->cd=$row["cd_id"];
                                $this->artist=$row["artist_id"];
                                $this->name=$row["t_name"];
                                $this->dur=$row["t_dur"];
                                $this->genre=$row["t_genre"];
                        }
                        else
                        {
                                $this->id=0;
                                $this->t_id=0;
                                $this->cd=0;
                                $this->artist=0;
                                $this->name="";
                                $this->dur="";
                                $this->genre="";
                        }
                        return $this;
                }
                
                function Track($id)
                {
                        $this->__construct($id);
                }
                
                function getTracks($cd_id)
                {
                        global $db, $prefix;
                        $sql="SELECT * FROM $prefix"."tracks where cd_id=$cd_id";
                        $res=$db->query($sql);
                        $id=0;
                        while($row=$res->fetchRow())
                        {
                                $ret[$id]["t_id"]=sprintf("%02d", $row["cd_t_id"]);
                                $artist=new Artist($row["artist_id"]);
                                $ret[$id]["t_artist"]="$artist->fname $artist->name";
                                $ret[$id]["t_artist_id"]=$artist->id;
                                $ret[$id]["a_pic"]=$artist->pic;
                                $ret[$id]["t_name"]=$row["t_name"];
                                $ret[$id]["t_dur"]=$row["t_dur"];
                                $id++;
                        }
                        return $ret;
                }
        }
?>