Subversion-Projekte lars-tiefland.em_wm

Revision

Revision 92 | Revision 114 | 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
 
28 lars 42
		function update($g_name, $g_m1, $g_m2, $g_g1, $g_g2, $g_location, $g_date, $g_type)
43
		{
31 lars 44
			$this->g_name=$g_name;
45
			$this->g_m1=$g_m1;
46
			$this->g_m2=$g_m2;
47
			$this->g_g1=$g_g1;
48
			$this->g_g2=$g_g2;
49
			$this->g_location=$g_location;
50
			$this->g_date=$g_date;
51
			$this->g_type=$g_type;
28 lars 52
		}
53
		function save($op)
54
		{
30 lars 55
			global $db;
28 lars 56
			switch($op)
57
			{
58
				case "save":
59
					$sql="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)";
61
					break;
62
				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";
64
					break;
37 lars 65
				case "delete":
28 lars 66
					$sql="DELETE FROM games WHERE g_id=$this->g_id";
67
					break;
68
			}
30 lars 69
			return $db->query($sql);
28 lars 70
		}
31 lars 71
 
72
		function ListSpiele($limit, $start=0)
73
		{
74
			global $db, $db_meld, $error, $meld, $user;
111 lars 75
			$sql="SELECT * FROM games ORDER BY g_date, g_name";
31 lars 76
			if ($db->provides('limit') && $limit > 0)
77
			{
78
				$res=$db->limitquery($sql, $start, $limit);
79
			}
80
			else
81
			{
82
				$res=$db->query($sql);
83
			}
84
			if (true == DB::isError($res))
85
			{
86
				$error=true;
87
				$meld="Ein Fehler ist aufgetreten!";
88
				$db_meld=$res->getUserInfo();
89
			}
90
			return $res;
91
		}
3 lars 92
	}
93
?>