當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DBObject::RecordAttChanges方法代碼示例

本文整理匯總了PHP中DBObject::RecordAttChanges方法的典型用法代碼示例。如果您正苦於以下問題:PHP DBObject::RecordAttChanges方法的具體用法?PHP DBObject::RecordAttChanges怎麽用?PHP DBObject::RecordAttChanges使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在DBObject的用法示例。


在下文中一共展示了DBObject::RecordAttChanges方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: RecordAttChanges

 protected function RecordAttChanges(array $aValues, array $aOrigValues)
 {
     parent::RecordAttChanges($aValues, $aOrigValues);
     // $aValues is an array of $sAttCode => $value
     //
     foreach ($aValues as $sAttCode => $value) {
         $oAttDef = MetaModel::GetAttributeDef(get_class($this), $sAttCode);
         if ($oAttDef->IsExternalField()) {
             continue;
         }
         if ($oAttDef->IsLinkSet()) {
             continue;
         }
         if ($oAttDef->GetTrackingLevel() == ATTRIBUTE_TRACKING_NONE) {
             continue;
         }
         if (array_key_exists($sAttCode, $aOrigValues)) {
             $original = $aOrigValues[$sAttCode];
         } else {
             $original = null;
         }
         if ($oAttDef instanceof AttributeOneWayPassword) {
             // One Way encrypted passwords' history is stored -one way- encrypted
             $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeOneWayPassword");
             $oMyChangeOp->Set("objclass", get_class($this));
             $oMyChangeOp->Set("objkey", $this->GetKey());
             $oMyChangeOp->Set("attcode", $sAttCode);
             if (is_null($original)) {
                 $original = '';
             }
             $oMyChangeOp->Set("prev_pwd", $original);
             $iId = $oMyChangeOp->DBInsertNoReload();
         } elseif ($oAttDef instanceof AttributeEncryptedString) {
             // Encrypted string history is stored encrypted
             $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeEncrypted");
             $oMyChangeOp->Set("objclass", get_class($this));
             $oMyChangeOp->Set("objkey", $this->GetKey());
             $oMyChangeOp->Set("attcode", $sAttCode);
             if (is_null($original)) {
                 $original = '';
             }
             $oMyChangeOp->Set("prevstring", $original);
             $iId = $oMyChangeOp->DBInsertNoReload();
         } elseif ($oAttDef instanceof AttributeBlob) {
             // Data blobs
             $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeBlob");
             $oMyChangeOp->Set("objclass", get_class($this));
             $oMyChangeOp->Set("objkey", $this->GetKey());
             $oMyChangeOp->Set("attcode", $sAttCode);
             if (is_null($original)) {
                 $original = new ormDocument();
             }
             $oMyChangeOp->Set("prevdata", $original);
             $iId = $oMyChangeOp->DBInsertNoReload();
         } elseif ($oAttDef instanceof AttributeStopWatch) {
             // Stop watches - record changes for sub items only (they are visible, the rest is not visible)
             //
             if (is_null($original)) {
                 $original = new OrmStopWatch();
             }
             foreach ($oAttDef->ListSubItems() as $sSubItemAttCode => $oSubItemAttDef) {
                 $item_value = $oSubItemAttDef->GetValue($value);
                 $item_original = $oSubItemAttDef->GetValue($original);
                 if ($item_value != $item_original) {
                     $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeScalar");
                     $oMyChangeOp->Set("objclass", get_class($this));
                     $oMyChangeOp->Set("objkey", $this->GetKey());
                     $oMyChangeOp->Set("attcode", $sSubItemAttCode);
                     $oMyChangeOp->Set("oldvalue", $item_original);
                     $oMyChangeOp->Set("newvalue", $item_value);
                     $iId = $oMyChangeOp->DBInsertNoReload();
                 }
             }
         } elseif ($oAttDef instanceof AttributeCaseLog) {
             $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeCaseLog");
             $oMyChangeOp->Set("objclass", get_class($this));
             $oMyChangeOp->Set("objkey", $this->GetKey());
             $oMyChangeOp->Set("attcode", $sAttCode);
             $oMyChangeOp->Set("lastentry", $value->GetLatestEntryIndex());
             $iId = $oMyChangeOp->DBInsertNoReload();
         } elseif ($oAttDef instanceof AttributeLongText) {
             // Data blobs
             $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeLongText");
             $oMyChangeOp->Set("objclass", get_class($this));
             $oMyChangeOp->Set("objkey", $this->GetKey());
             $oMyChangeOp->Set("attcode", $sAttCode);
             if (!is_null($original) && $original instanceof ormCaseLog) {
                 $original = $original->GetText();
             }
             $oMyChangeOp->Set("prevdata", $original);
             $iId = $oMyChangeOp->DBInsertNoReload();
         } elseif ($oAttDef instanceof AttributeText) {
             // Data blobs
             $oMyChangeOp = MetaModel::NewObject("CMDBChangeOpSetAttributeText");
             $oMyChangeOp->Set("objclass", get_class($this));
             $oMyChangeOp->Set("objkey", $this->GetKey());
             $oMyChangeOp->Set("attcode", $sAttCode);
             if (!is_null($original) && $original instanceof ormCaseLog) {
                 $original = $original->GetText();
             }
//.........這裏部分代碼省略.........
開發者ID:leandroborgeseng,項目名稱:bhtm,代碼行數:101,代碼來源:cmdbobject.class.inc.php


注:本文中的DBObject::RecordAttChanges方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。