Subversion-Projekte lars-tiefland.em_wm

Revision

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