Ejemplo n.º 1
0
 function Search($indexedbyid = false, $loose = false)
 {
     global $dbh;
     // Store any values that have been added before we make them safe
     foreach ($this as $prop => $val) {
         if (isset($val)) {
             $o[$prop] = $val;
         }
     }
     // Make everything safe for us to search with
     $this->MakeSafe();
     // This will store all our extended sql
     $sqlextend = "";
     foreach ($o as $prop => $val) {
         extendsql($prop, $this->{$prop}, $sqlextend, $loose);
     }
     $sql = "SELECT * FROM fac_Ports {$sqlextend} ORDER BY DeviceID, PortNumber ASC;";
     $portList = array();
     foreach ($dbh->query($sql) as $portRow) {
         if ($indexedbyid) {
             $portList[$portRow["DeviceID"] . $portRow["PortNumber"]] = DevicePorts::RowToObject($portRow);
         } else {
             $portList[] = DevicePorts::RowToObject($portRow);
         }
     }
     return $portList;
 }
Ejemplo n.º 2
0
 static function getPortList($DeviceID)
 {
     global $dbh;
     $dev = new Device();
     $dev->DeviceID = $DeviceID;
     if (!$dev->GetDevice()) {
         return false;
         // This device doesn't exist
     }
     $sql = "SELECT * FROM fac_Ports WHERE DeviceID={$dev->DeviceID};";
     $portList = array();
     foreach ($dbh->query($sql) as $row) {
         $portList[$row['PortNumber']] = DevicePorts::RowToObject($row);
     }
     if (sizeof($portList) == 0 && $dev->DeviceType != "Physical Infrastructure") {
         // somehow this device doesn't have ports so make them now
         $portList = DevicePorts::createPorts($dev->DeviceID);
     }
     return $portList;
 }