Subversion-Projekte lars-tiefland.em_wm

Revision

Revision 114 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
132 lars 1
<?php
114 lars 2
    class Spiele
3
    {
4
        var $g_id;
5
        var $g_name;
6
        var $g_m1;
7
        var $g_m2;
8
        var $g_g1;
9
        var $g_g2;
10
        var $g_location;
11
        var $g_date;
12
        var $g_type;
13
 
14
        function __construct( $g_id )
15
        {
16
            global $db, $db_meld, $error, $meld, $user;
17
            $sql = "SELECT * FROM games WHERE g_id=$g_id";
18
            $res = $db->query( $sql );
19
            if ( true == DB::isError($res) )
20
            {
21
                $error = true;
22
                $meld = "Ein Fehler ist aufgetreten!";
23
                $db_meld = $res->getUserInfo();
24
                return $error;
25
            }
26
            else
27
            {
28
                $row = $res->fetchRow();
29
                $this->g_id = $g_id;
30
                $this->g_name = $row["g_name"];
31
                $this->g_m1 = $row["g_m1"];
32
                $this->g_m2 = $row["g_m2"];
33
                $this->g_g1 = $row["g_g1"];
34
                $this->g_g2 = $row["g_g2"];
35
                $this->g_location = $row["g_location"];
36
                $this->g_date = $row["g_date"];
37
                $this->g_type = $row["g_type"];
38
                return $this;
39
            }
40
        }
41
 
42
        function update( $g_name, $g_m1, $g_m2, $g_g1, $g_g2, $g_location, $g_date,
43
            $g_type )
44
        {
45
            $this->g_name = $g_name;
46
            $this->g_m1 = $g_m1;
47
            $this->g_m2 = $g_m2;
48
            $this->g_g1 = $g_g1;
49
            $this->g_g2 = $g_g2;
50
            $this->g_location = $g_location;
51
            $this->g_date = $g_date;
52
            $this->g_type = $g_type;
53
        }
54
        function save( $op )
55
        {
56
            global $db;
57
            switch ( $op )
58
            {
59
                case "save":
60
                    $sql =
61
                        "INSERT INTO games (g_name, g_m1, g_m2, g_g1, g_g2, g_location, g_date, g_type)
28 lars 62
						VALUES ('$this->g_name', $this->g_m1, $this->g_m2, $this->g_g1, $this->g_g2, $this->g_location, $this->g_date, $this->g_type)";
114 lars 63
                    break;
64
                case "update":
65
                    $sql = "UPDATE games SET g_name='$this->g_name', g_m1=$this->g_m1, g_m2=$this->g_m2, g_g1=$this->g_g1, g_g2=$this->g_g2, g_location=$this->g_location, g_date=$this->g_date, g_type=$this->g_type WHERE g_id=$this->g_id";
66
                    break;
67
                case "delete":
68
                    $sql = "DELETE FROM games WHERE g_id=$this->g_id";
69
                    break;
70
            }
71
            return $db->query( $sql );
72
        }
73
 
74
        function ListSpiele( $limit, $start = 0 )
75
        {
76
            global $db, $db_meld, $error, $meld, $user;
77
            $sql = "SELECT * FROM games ORDER BY g_date, g_name";
78
            if ( $db->provides('limit') && $limit > 0 )
79
            {
80
                $res = $db->limitquery( $sql, $start, $limit );
81
            }
82
            else
83
            {
84
                $res = $db->query( $sql );
85
            }
86
            if ( true == DB::isError($res) )
87
            {
88
                $error = true;
89
                $meld = "Ein Fehler ist aufgetreten!";
90
                $db_meld = $res->getUserInfo();
91
            }
92
            return $res;
93
        }
94
    }
3 lars 95
?>