Subversion-Projekte lars-tiefland.medien

Revision

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

<?
        Class Artist
        {
                var $id;
                var $name;
                var $fname;
                var $pic;

                function __construct($id=0)
                {
                        global $db, $prefix, $db_meld;
                        if ($id)
                        {
                                $sql="SELECT * FROM $prefix"."artist WHERE artist_id=$id";
                                $res=$db->query($sql);
                                if (DB::isError($res))
                                {
                                        $db_meld=$res->getUserInfo();
                                }
                                else
                                {
                                        $row=$res->fetchRow();
                                        $this->id=$id;
                                        $this->name=$row["artist_name"];
                                        $this->fname=$row["artist_fname"];
                                        $this->pic =$row["artist_pic"];
                                }
                        }
                        else
                        {
                                $this->id=0;
                                $this->name="";
                                $this->fname="";
                                $this->pic="";
                        }
                        return $this;
                }
                function Artist($id=0)
                {
                        $this->__construct($id);
                }

                function update($a_name, $a_pic, $a_fname)
                {
                        $this->name=$a_name;
                        $this->fname=$a_fname;
                        $this->pic=$a_pic;
                }

                function save($mode="save")
                {
                        global $db, $prefix;
                        switch ($mode)
                        {
                                case "save":
                                        $sql="INSERT INTO $prefix"."artist (artist_name, artist_fname, artist_pic) VALUES ('$this->name', '$this->fname', '$this->pic')";
                                        break;
                                case "update":
                                        $pic_sql="";
                                        if ($this->pic)
                                        {
                                                $pic_sql=", artist_pic='$this->pic'";
                                        }
                                        $sql="UPDATE $prefix"."artist SET artist_name='$this->name', artist_fname='$this->fname'".$pic_sql." WHERE artist_id=$this->id";
                                        break;
                                case "del":
                                        break;
                        }
                        return $db->query($sql);
                }
        }
?>