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


PHP Audit::getErrors方法代码示例

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


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

示例1: add

 public static function add($target, $action, $data = null, $log_message = null, $properties = array())
 {
     if (!($_target = AuditType::model()->find('name=?', array($target)))) {
         $_target = new AuditType();
         $_target->name = $target;
         if (!$_target->save()) {
             throw new Exception("Unable to save audit target: " . print_r($_target->getErrors(), true));
         }
     }
     if (!($_action = AuditAction::model()->find('name=?', array($action)))) {
         $_action = new AuditAction();
         $_action->name = $action;
         if (!$_action->save()) {
             throw new Exception("Unable to save audit action: " . print_r($_action->getErrors(), true));
         }
     }
     $audit = new Audit();
     $audit->type_id = $_target->id;
     $audit->action_id = $_action->id;
     $audit->data = $data;
     if (!isset($properties['user_id'])) {
         if (Yii::app()->session['user']) {
             $properties['user_id'] = Yii::app()->session['user']->id;
         }
     }
     if (isset($properties['module'])) {
         if ($et = EventType::model()->find('class_name=?', array($properties['module']))) {
             $properties['event_type_id'] = $et->id;
         } else {
             if (!($module = AuditModule::model()->find('name=?', array($properties['module'])))) {
                 $module = new AuditModule();
                 $module->name = $properties['module'];
                 if (!$module->save()) {
                     throw new Exception("Unable to create audit_module: " . print_r($module->getErrors(), true));
                 }
             }
             $properties['module_id'] = $module->id;
         }
         unset($properties['module']);
     }
     if (isset($properties['model'])) {
         if (!($model = AuditModel::model()->find('name=?', array($properties['model'])))) {
             $model = new AuditModel();
             $model->name = $properties['model'];
             if (!$model->save()) {
                 throw new Exception("Unable to save audit_model: " . print_r($model->getErrors(), true));
             }
         }
         $properties['model_id'] = $model->id;
         unset($properties['model']);
     }
     foreach ($properties as $key => $value) {
         $audit->{$key} = $value;
     }
     if (!$audit->save()) {
         throw new Exception("Failed to save audit entry: " . print_r($audit->getErrors(), true));
     }
     if (isset($properties['user_id'])) {
         $username = User::model()->findByPk($properties['user_id'])->username;
     }
     $log_message && OELog::log($log_message, @$username);
     return $audit;
 }
开发者ID:code-4-england,项目名称:OpenEyes,代码行数:63,代码来源:Audit.php

示例2: logAudit

 /**
  * Description: logs an audit on the database, 
  * ¡¡ assumes that there is an active transaction !!
  * @param type $user
  * @param type $dateTime
  * @param type $object
  * @param type $operation
  * @param type $description
  * @throws \Exception
  */
 public function logAudit($user, $dateTime, $object, $operation, $description)
 {
     $a = new Audit();
     $a->description = $description;
     $a->date_time = $dateTime->getTimestamp();
     $a->user = $user;
     $a->object = $object;
     $a->operation = $operation;
     if (!$a->save()) {
         throw new \Exception("Error logging audit: " + CJSON::encode($a->getErrors()));
     }
 }
开发者ID:pelo8888,项目名称:php-angular-yii,代码行数:22,代码来源:Audit.php


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