Ignore:
Timestamp:
Feb 25, 2022, 9:30:55 AM (3 years ago)
Author:
chronos
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Network/NetworkModels.php

    r911 r921  
    192192    $Desc = new ModelDesc(self::GetClassName());
    193193    $Desc->AddDateTime('Time');
    194     $Desc->AddString('MAC');
     194    $Desc->AddReference('MAC', NetworkMac::GetClassName());
    195195    $Desc->AddReference('Interface', NetworkInterface::GetClassName());
    196196    $Desc->AddInteger('Value');
     
    342342  }
    343343}
     344
     345class NetworkMac extends Model
     346{
     347  static function GetModelDesc(): ModelDesc
     348  {
     349    $Desc = new ModelDesc(self::GetClassName());
     350    $Desc->AddString('MAC'); // size=17
     351    return $Desc;
     352  }
     353
     354  function GetIndex(string $MAC)
     355  {
     356    $DbResult = $this->Database->select('NetworkMac', 'Id', 'MAC="'.$MAC.'"');
     357    if ($DbResult->num_rows > 0)
     358    {
     359      $DbRow = $DbResult->fetch_assoc();
     360      return $DbRow['Id'];
     361    } else
     362    {
     363      return $this->Database->insert('NetworkMac', array('MAC' => $MAC));
     364    }
     365  }
     366}
Note: See TracChangeset for help on using the changeset viewer.