Subversion-Projekte lars-tiefland.inventar

Revision

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

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