本文整理汇总了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;
}