Subversion-Projekte lars-tiefland.em_wm

Revision

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

<?
    class Team
    {
        var $t_id;
        var $t_name;
        var $t_group;
        var $t_aus;

        function __construct( $t_id )
        {
            global $db, $db_meld, $error, $meld;
            $t_id = intval( $t_id );
            $sql = "SELECT * FROM teams WHERE t_id=$t_id";
            $res = $db->query( $sql );
            if ( true == DB::isError($res) )
            {
                $error = "true";
                $meld = "Ein Fehler ist aufgetreten!";
                $db_meld = $res->getUserInfo();
                return $error;
            }
            else
            {
                $row = $res->fetchRow();
                $this->t_id = $t_id;
                $this->t_name = $row["t_name"];
                $this->t_group = $row["t_group"];
                $this->t_aus = $row["t_aus"];
                $this->t_flag = $row["t_flag"];
                return $this;
            }
        }

        function update( $t_name, $t_group )
        {
            $this->t_name = $t_name;
            $this->t_group = $t_group;
        }

        function save( $op )
        {
            global $db;
            switch ( $op )
            {
                case "save":
                    $sql = "INSERT INTO teams (t_name, t_group)
                                                VALUES ('$this->t_name', $this->t_group)";
                    break;
                case "update":
                    $sql = "UPDATE teams SET t_name='$this->t_name', t_group=$this->t_group WHERE t_id=$this->t_id";
                    break;
                case "delete":
                    $sql = "DELETE FROM teams WHERE t_id=$this->t_id";
                    break;
            }
            return $db->query( $sql );
        }

        function listeTeam( $limit, $start = 0 )
        {
            global $db, $db_meld, $error, $meld, $user;
            $sql = "SELECT * FROM teams";
            if ( $db->provides('limit') && $limit > 0 )
            {
                $res = $db->limitquery( $sql, $start, $limit );
            }
            else
            {
                $res = $db->query( $sql );
            }
            if ( true == DB::isError($res) )
            {
                $error = true;
                $meld = "Ein Fehler ist aufgetreten!";
                $db_meld = $res->getUserInfo();
            }
            return $res;
        }
    }
?>