本文整理汇总了PHP中AdminAction::save方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminAction::save方法的具体用法?PHP AdminAction::save怎么用?PHP AdminAction::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminAction
的用法示例。
在下文中一共展示了AdminAction::save方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addActionNotes
/**
* add action notes
*
* @author youzhao.zxw<swustnjtu@gmail.com>
* @param string $tableName target table name
* @param string $action edit action
* @param array $newRecordAttributes new record attributes
* @param array $oldRecordAttributs old record attributes
* @return array add action notes result
*/
public static function addActionNotes($tableName, $action, $newRecordAttributes, $oldRecordAttributs)
{
$infoAction = new AdminAction();
$infoAction->action_type = $action;
$infoAction->target_table = $tableName;
$infoAction->target_id = $newRecordAttributes['id'];
if (!$infoAction->save()) {
$resultInfo['status'] = CommonService::$ApiResult['FAIL'];
$resultInfo['detail'] = $infoAction->getErrors();
return $resultInfo;
} else {
if (!empty($oldRecordAttributs)) {
$diffAttributeArr = self::compareRecord($oldRecordAttributs, $newRecordAttributes);
foreach ($diffAttributeArr as $diffInfo) {
$actionHistory = new AdminHistory();
$actionHistory->action_field = $diffInfo[0];
$actionHistory->adminaction_id = $infoAction->id;
$actionHistory->old_value = $diffInfo[1];
$actionHistory->new_value = $diffInfo[2];
if (!$actionHistory->save()) {
$resultInfo['status'] = CommonService::$ApiResult['FAIL'];
$resultInfo['detail'] = $actionHistory->getErrors();
return $resultInfo;
}
}
}
}
$resultInfo['status'] = CommonService::$ApiResult['SUCCESS'];
$resultInfo['detail'] = array('id' => $infoAction->id);
return $resultInfo;
}
示例2: add
/**
* 新增一条管理员操作记录
* @param type $attr
* @return boolean
*/
public static function add($attr)
{
if (empty($attr)) {
return false;
}
$modelAA = new AdminAction();
$modelAA->attributes = $attr;
if ($modelAA->save()) {
return true;
}
return false;
}
示例3: record
public static function record($type, $logid = 0)
{
if ($type == '') {
return false;
}
if (Yii::app()->user->isGuest) {
return false;
}
$uid = Yii::app()->user->id;
$desc = GroupPowers::getDesc('admin', $type);
if ($desc == '') {
return false;
}
$data = array('uid' => $uid, 'logid' => $logid, 'classify' => $type, 'description' => $desc, 'ip' => ip2long(Yii::app()->request->userHostAddress), 'cTime' => time());
$model = new AdminAction();
$model->attributes = $data;
if ($model->save()) {
return true;
} else {
return false;
}
}