本文整理汇总了PHP中app\models\Log::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Log::save方法的具体用法?PHP Log::save怎么用?PHP Log::save使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Log
的用法示例。
在下文中一共展示了Log::save方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newLog
public static function newLog($type, $msg)
{
$log = new Log();
$log->type = $type;
$log->msg = $msg;
$log->created_time = time();
return $log->save();
}
示例2: actionCreate
/**
* Creates a new Log model.
* If creation is successful, the browser will be redirected to the 'view' page.
* @return mixed
*/
public function actionCreate()
{
$model = new Log();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('create', ['model' => $model]);
}
}
示例3: actionMessage
public function actionMessage()
{
$model = new Log();
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect($model->goal->url(['#' => 'log']));
} else {
throw new ErrorException('Cannot add message');
}
}
示例4: updateLog
public function updateLog()
{
$model = Log::findOne($this->id);
if (!$model) {
$model = new Log();
$model->source_id = $this->id;
}
$model->updated = date("Y-m-d H:i:s");
return $model->save();
}
示例5: createLog
public function createLog($data)
{
$log = new Log();
$log->log_name = $data['log_name'];
$log->log_description = $data['log_description'];
$log->duration = $data['duration'];
$log->status = $data['status'];
$log->retrieved_from = $data['retrieved_from'];
$log->is_group_log = $data['is_group_log'];
$log->priority = $data['priority'];
$log->list_id = $data['list_id'];
$log->user_id = $this->auth->id();
$log->save();
}
示例6: actionUpdate
/**
* Updates an existing Equipment model.
* If update is successful, the browser will be redirected to the 'view' page.
* @param string $id
* @return mixed
*/
public function actionUpdate($id)
{
$model = $this->findModel($id);
$model->room_id = $model->location->room_id;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
//Las siguientes líneas de código almacenan en la tabla Log información de acerca de las actualizaciones en los equipos
$modelLog = new Log();
$modelLog->user_id = Yii::$app->user->id;
$modelLog->date = new \yii\db\Expression('NOW()');
$modelLog->log_type_id = 3;
$modelLog->equipment_id = $model->id;
$modelLog->location_id = $model->location_id;
$modelLog->equipment_status_id = $model->equipment_status_id;
$modelLog->save();
return $this->redirect(['view', 'id' => $model->id]);
} else {
return $this->render('update', ['model' => $model]);
}
}
示例7: afterSave
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
$oLog = new Log();
$oLog->message = $this->log_message;
$oLog->goal_id = $this->id;
$aChanged = [];
foreach ($changedAttributes as $sName => $sVal) {
$mNewVal = $this->getAttribute($sName);
if (is_int($sVal)) {
$mNewVal = (int) $mNewVal;
}
if ($sVal != $this->getAttribute($sName)) {
$aChanged[$sName] = [$sVal, $mNewVal];
}
}
if (isset($aChanged['updated_at'])) {
unset($aChanged['updated_at']);
}
$oLog->data = json_encode($aChanged);
$oLog->save();
}
示例8: explode
function html_str($url)
{
/*
$qihao = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('em[class=red]',0)->innertext;
$code1 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',0)->innertext;
$code2 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',1)->innertext;
$code3 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',2)->innertext;
$code4 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',3)->innertext;
$code5 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('ul[id=open_code_list]',0)->find('li[class=ico-ball3]',4)->innertext;
$msg = $this->grab->find('div[class=mod-aside mod-aside-xssckj]',0)->find('div[class=hd clearfix]',0)->find('p[class=kj-date]',0)->find('em[class=kj-date-txt]',0)->innertext;
echo $qihao.'<br/>';
echo $code1.'<br/>';
echo $code2.'<br/>';
echo $code3.'<br/>';
echo $code4.'<br/>';
echo $code5.'<br/>';
echo $msg.'<br/>';
exit;
*/
$qihao2 = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 0)->plaintext;
$code = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 1)->plaintext;
if ($code != '--') {
// == '--' 正在开奖中
$isKaiJiang = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->plaintext;
if ($isKaiJiang != '--' && $isKaiJiang != '开奖中') {
//能读取到数据
$sizeProportion = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 0)->plaintext;
$jioubili = $this->grab->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 1)->plaintext;
$codeArr = explode(" ", $code);
list($one, $two, $three, $four, $five) = $codeArr;
$result = Code::findOne(['qishu' => $qihao2, 'type' => $this->codeType[$url]]);
if ($result) {
$urlName = array_keys($this->urlArr, $url);
echo $urlName[0] . ' - [新时时彩] 最新数据已经采集过了<br/>';
return;
}
$model = new Code();
$model->qishu = $qihao2;
$model->one = $one;
$model->two = $two;
$model->three = $three;
$model->four = $four;
$model->five = $five;
$model->type = $this->codeType[$url];
$model->size = $sizeProportion;
$model->jiou = $jioubili;
$model->time = time();
if ($model->validate() && $model->save()) {
$urlName = array_keys($this->urlArr, $url);
$logModel = new Log();
$logModel->type = 1;
$logModel->content = $urlName[0] . '.开奖信息抓取成功';
$logModel->time = time();
$logModel->save();
echo $urlName[0] . '.开奖信息抓取成功-[新时时彩]<br/>';
$this->find($qihao2, $urlName[0], $codeArr, $model->id);
return;
}
} else {
$urlName = array_keys($this->urlArr, $url);
echo $urlName[0] . '等待开奖...<br/>';
}
} else {
$urlName = array_keys($this->urlArr, $url);
echo $urlName[0] . ' -[新时时彩] 等待开奖...<br/>';
return;
}
}
示例9: setLog
/**
* 记录日志
* @param bool $state 操作状态;
* @param string $content 操作内容;
*/
private function setLog($state = true, $content = '')
{
$state == true ? $type = 1 : ($type = 2);
//抓取网页失败 记录日志
$logModel = new Log();
$logModel->type = $type;
$logModel->content = $content;
$logModel->time = time();
$logModel->save();
}
示例10: checkAnswer
public static function checkAnswer($post, $model)
{
$answerType = 'Ошибка';
$answer = $post['Challenge']['answer'];
if (!empty($answer)) {
if ($model->is_answer_activate == 0) {
if ($answer == $model->answer) {
$model->is_answer_activate = 1;
$answerType = 'Ответ введен верно';
$model->save(false);
} else {
$answerType = 'Ответ введен не верно';
}
} else {
$checkSum = (string) (ord($answer[6]) + $answer[7]);
$answerId = $checkSum[2];
if (strlen($answer) == 8 && $answer[0] == 'z' && $answer[1] == 'p' && $answerId == $model->id) {
$answerType = 'Код введен верно';
$model->code_count = $model->code_count + 1;
$model->save(false);
} else {
$answerType = 'Код введен не верно';
}
}
$log = new Log();
$log->time = time();
$log->text = $answerType;
$log->challenge_id = $model->id;
$log->answer = $answer;
$log->save();
}
}
示例11: afterSave
/**
* @inheritdoc
*/
public function afterSave($insert, $changedAttributes)
{
parent::afterSave($insert, $changedAttributes);
// add log record on task creation
if ($insert) {
$log = new Log(['data' => json_encode(['add_task' => ['id' => $this->id, 'title' => $this->title]]), 'goal_id' => $this->goal_id]);
$log->save();
} elseif (isset($changedAttributes['closed']) and !$changedAttributes['closed'] and $this->closed) {
// add log record
$log = new Log(['data' => json_encode(['close_task' => ['id' => $this->id, 'title' => $this->title]]), 'goal_id' => $this->goal_id]);
$log->save();
// upd percent if needed
if ($this->percent and $this->percent > $this->goal->percent) {
$this->goal->percent = $this->percent;
$this->goal->save();
}
}
}
示例12: beforeAction
public function beforeAction($action)
{
parent::beforeAction($action);
$act = $action->id;
$controller = $action->controller->id;
$user = Yii::$app->session->get('user');
$log = new Log();
$log->url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER["REQUEST_URI"];
$log->method = Yii::$app->request->method;
$log->controller = $controller;
$log->action = $act;
if ($user != null) {
$log->uid = $user->id;
}
$log->log_time = date('Y-m-d H:i:s');
$log->save();
if ($controller == 'site') {
return true;
}
if (Yii::$app->user->isGuest && $act != 'guest-create') {
$this->redirect('/site/login');
}
if ($this->isPermiss($user, $controller, $act)) {
return true;
} else {
throw new MethodNotAllowedHttpException('未被授权!');
}
}
示例13: html_str
private function html_str($url)
{
$qihao = $this->grab->find('div[class=aside]', 0)->find('h3', 0)->find('em', 0)->plaintext;
$code = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 1)->plaintext;
if ($code != '--') {
$isKaiJiang = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->plaintext;
if ($isKaiJiang != '--' && $isKaiJiang != '开奖中') {
//能读取到数据
$h3_shape = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 0)->plaintext;
$h3_size = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 1)->plaintext;
$h3_jiou = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 2)->find('span', 2)->plaintext;
$h2_shape = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 3)->find('span', 0)->plaintext;
$h2_10wei = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 3)->find('span', 1)->plaintext;
$h2_gewei = $this->grab->find('div[class=aside]', 0)->find('div[class=mod-aside mod-aside-xssckj]', 0)->find('div[class=bd]', 0)->find('div[class=kpkjcode]', 0)->find('table', 0)->find('tr', 1)->find('td', 3)->find('span', 2)->plaintext;
/*
echo '开奖期号:'.$qihao;
echo '<br/>';
echo '开奖号码:'.$code;
echo '<br/>';
echo '<br/>';
echo '后3形态:'.$h3_shape;
echo '<br/>';
echo '后3大小比:'.$h3_size;
echo '<br/>';
echo '后3奇偶比:'.$h3_jiou;
echo '<br/>';
echo '<br/>';
echo '后2形态:'.$h2_shape;
echo '<br/>';
echo '后2大小比:'.$h2_10wei;
echo '<br/>';
echo '后2奇偶比:'.$h2_gewei;
*/
$result = Codeold::findOne(['qishu' => $qihao, 'type' => $this->codeType[$url]]);
if ($result) {
$urlName = array_keys($this->urlArr, $url);
echo $urlName[0] . ' 最新数据已经采集过了<br/>';
return;
}
$model = new Codeold();
$model->qishu = $qihao;
$model->code = $code;
$model->after_three_shape = $h3_shape;
$model->after_three_size = $h3_size;
$model->after_three_jiou = $h3_jiou;
$model->after_two_shape = $h2_shape;
$model->after_two_tens_place = $h2_10wei;
$model->after_two_the_unit = $h2_gewei;
$model->type = $this->codeType[$url];
$model->time = time();
if ($model->validate() && $model->save()) {
$urlName = array_keys($this->urlArr, $url);
$logModel = new Log();
$logModel->type = 1;
$logModel->content = $urlName[0] . '.开奖信息抓取成功';
$logModel->time = time();
$logModel->save();
echo $urlName[0] . '.开奖信息抓取成功<br/>';
$this->find($qihao, $urlName[0], $code, $model->id);
return;
}
} else {
$urlName = array_keys($this->urlArr, $url);
echo $urlName[0] . '等待开奖...<br/>';
}
} else {
$urlName = array_keys($this->urlArr, $url);
echo $urlName[0] . '等待开奖...<br/>';
}
}
示例14: reviewed
public static function reviewed(Log $log)
{
$log->review_date = \Carbon\Carbon::now();
$log->save();
}