Subversion-Projekte lars-tiefland.em_wm

Revision

Revision 37 | Revision 92 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

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