Subversion-Projekte lars-tiefland.inventar

Revision

Revision 7 | Revision 18 | Zur aktuellen Revision | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
4 lars 1
<?php
2
 
3
	//$Id: comp.class.php 14 2008-05-15 18:19:36Z lars $
4
 
7 lars 5
	/**
6
	 * @package	Inventar Datenbank
7
	 * @author Lars Tiefland <ltiefland@gmail.com>
8
	 * @copyright 2008
9
	 **/
4 lars 10
 
11
	class comp{
12
		private $id;
13
		private $name;
14
		private $os_id;
15
 
16
		function __construct($id=0)
17
		{
18
			if($id)
19
			{
20
				$res=$GLOBALS["db"]->query("SELECT * FROM computer WHERE id=$id");
21
				$this->id=$id;
5 lars 22
				$row=$res->fetchRow();
4 lars 23
				$this->name=$row["name"];
24
			}
25
			else
26
			{
27
				$this->id=0;
28
				$this->name='';
29
				$this->os_id=1;
30
			}
31
		}
32
		static function get_computers($start=0,$limit=0)
33
		{
34
			$sql="SELECT * FROM computer";
35
			if($limit)
36
			{
37
				$res=$GLOBALS["db"]->limiquery($sql,$start,$limit);
38
			}
39
			else
40
			{
41
				$res=$GLOBALS["db"]->query($sql);
42
			}
5 lars 43
			while($row=$res->fetchRow())
4 lars 44
			{
45
				$comp[]=$row;
46
			}
47
			return $comp;
48
		}
14 lars 49
 
50
		function toArray()
51
		{
52
			$ret["name"]=$this->name;
53
			$ret["id"]=$this->id;
54
			$ret["os_id"]=$this->os_id;
55
			$os=new os($this->os_id);
56
			$ret["os_name"]=$os->getName();
57
			return $ret;
58
		}
4 lars 59
	}
60
 
61
?>