Subversion-Projekte lars-tiefland.inventar

Revision

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

Revision Autor Zeilennr. Zeile
4 lars 1
<?php
2
 
3
	//$Id: comp.class.php 20 2008-05-15 19:12:18Z 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"];
18 lars 24
				$this->os_id=$row["os_id"];
4 lars 25
			}
26
			else
27
			{
28
				$this->id=0;
29
				$this->name='';
30
				$this->os_id=1;
31
			}
32
		}
33
		static function get_computers($start=0,$limit=0)
34
		{
35
			$sql="SELECT * FROM computer";
36
			if($limit)
37
			{
38
				$res=$GLOBALS["db"]->limiquery($sql,$start,$limit);
39
			}
40
			else
41
			{
42
				$res=$GLOBALS["db"]->query($sql);
43
			}
5 lars 44
			while($row=$res->fetchRow())
4 lars 45
			{
46
				$comp[]=$row;
47
			}
48
			return $comp;
49
		}
14 lars 50
 
51
		function toArray()
52
		{
53
			$ret["name"]=$this->name;
54
			$ret["id"]=$this->id;
55
			$ret["os_id"]=$this->os_id;
20 lars 56
			$temp=new os($this->os_id);
57
			$os=$temp->toArray();
58
			$ret["os_name"]=$os["name"];
14 lars 59
			return $ret;
60
		}
4 lars 61
	}
62
 
63
?>