Subversion-Projekte lars-tiefland.em_wm

Revision

Revision 111 | Zur aktuellen Revision | Ganze Datei anzeigen | Leerzeichen ignorieren | Details | Blame | Letzte Änderung | Log anzeigen | RSS feed

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