当前位置: 首页>>代码示例>>PHP>>正文


PHP LogActions::WriteToDB方法代码示例

本文整理汇总了PHP中LogActions::WriteToDB方法的典型用法代码示例。如果您正苦于以下问题:PHP LogActions::WriteToDB方法的具体用法?PHP LogActions::WriteToDB怎么用?PHP LogActions::WriteToDB使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在LogActions的用法示例。


在下文中一共展示了LogActions::WriteToDB方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: LogThis


//.........这里部分代码省略.........
     switch ($log->Class) {
         case "Device":
             $log->ObjectID = $object->DeviceID;
             break;
         case "Cabinet":
             $log->ObjectID = $object->CabinetID;
             break;
         case "CabinetAudit":
             $log->ObjectID = $object->CabinetID;
             break;
         case "DevicePorts":
             $log->ObjectID = $object->DeviceID;
             $log->ChildID = $object->PortNumber;
             // The two following functions are not logged
             // DevicePorts::removeConnections()
             // DevicePorts::removePorts()
             break;
         case "PowerPorts":
             $log->ObjectID = $object->DeviceID;
             $log->ChildID = $object->PortNumber;
             break;
         case "TemplatePorts":
             $log->ObjectID = $object->TemplateID;
             $log->ChildID = $object->PortNumber;
             break;
         case "RackRequest":
             $log->ObjectID = $object->RequestID;
             break;
         case "Slot":
             $log->ObjectID = $object->TemplateID;
             $log->ChildID = $object->Position;
             break;
         case "SensorTemplate":
             $log->ObjectID = $object->TemplateID;
             break;
         case "PowerConnection":
             $log->ObjectID = $object->DeviceID;
             $log->ChildID = $object->DeviceConnNumber;
             break;
             // similar questions as to the switch connections. are we going to track this?
         // similar questions as to the switch connections. are we going to track this?
         case "SupplyBin":
         case "Supplies":
         case "Config":
             // do we want to track when the default system config has been updated?
         // do we want to track when the default system config has been updated?
         case "PowerDistribution":
         case "CDUTemplate":
         case "PowerPanel":
             // only has create and update. should changes here be logged or figure out what changed and log that?
         // only has create and update. should changes here be logged or figure out what changed and log that?
         case "DeviceTemplate":
             // The following function isn't logged
             // UpdateDevice()
         // The following function isn't logged
         // UpdateDevice()
         case "Department":
             // Not sure how to go about tracking the changes in membership
         // Not sure how to go about tracking the changes in membership
         default:
             // Attempt to autofind the id of the object we've been handed
             foreach ($object as $prop => $value) {
                 if (preg_match("/ID/", $prop)) {
                     $log->ObjectID = $value;
                     break;
                 }
             }
     }
     $return = true;
     // If there are any differences then we are upating an object otherwise
     // this is a new object so just log the action as a create
     if (!is_null($originalobject)) {
         if (count($diff)) {
             foreach ($diff as $key => $value) {
                 $log->Property = $key;
                 // Suppressing errors here because if a new value exists on the object there won't be one in the
                 // original and it will throw an error on the web server
                 @($log->OldVal = $originalobject->{$key});
                 $log->NewVal = $object->{$key};
                 $return = $log->WriteToDB() ? $return : false;
             }
         }
         // in the event that two objects were passed but no changes found,
         // we just wrote the same info back to the db, nothing to log
     } else {
         // if we're creating a new object make a note of all the values
         if ($log->Action == 1) {
             foreach ($object as $prop => $value) {
                 $log->Property = $prop;
                 $log->NewVal = $value;
                 // Log only new object properties that have values
                 // this should cut down on the amount of useless junk we are putting into the log
                 $return = $log->NewVal ? $log->WriteToDB() : true;
             }
         } else {
             $return = $log->WriteToDB();
         }
     }
     return $return;
 }
开发者ID:aliyildiz84,项目名称:openDCIM,代码行数:101,代码来源:logging.inc.php


注:本文中的LogActions::WriteToDB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。