Subversion-Projekte lars-tiefland.inventar

Revision

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

<?php

        //$Id: comp.class.php 20 2008-05-15 19:12:18Z lars $
        
        /**
         * @package     Inventar Datenbank
         * @author Lars Tiefland <ltiefland@gmail.com>
         * @copyright 2008
         **/

        class comp{
                private $id;
                private $name;
                private $os_id;
                
                function __construct($id=0)
                {
                        if($id)
                        {
                                $res=$GLOBALS["db"]->query("SELECT * FROM computer WHERE id=$id");
                                $this->id=$id;
                                $row=$res->fetchRow();
                                $this->name=$row["name"];       
                                $this->os_id=$row["os_id"];
                        }
                        else
                        {
                                $this->id=0;
                                $this->name='';
                                $this->os_id=1;
                        }
                }
                static function get_computers($start=0,$limit=0)
                {
                        $sql="SELECT * FROM computer";
                        if($limit)
                        {
                                $res=$GLOBALS["db"]->limiquery($sql,$start,$limit);
                        }
                        else
                        {
                                $res=$GLOBALS["db"]->query($sql);
                        }
                        while($row=$res->fetchRow())
                        {
                                $comp[]=$row;
                        }
                        return $comp;
                }
                
                function toArray()
                {
                        $ret["name"]=$this->name;
                        $ret["id"]=$this->id;
                        $ret["os_id"]=$this->os_id;
                        $temp=new os($this->os_id);
                        $os=$temp->toArray();
                        $ret["os_name"]=$os["name"];
                        return $ret;
                }
        }

?>