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


PHP yii::log方法代碼示例

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


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

示例1: actionAlarm

 public function actionAlarm()
 {
     $mes = $_REQUEST['ids'];
     $mes = json_decode($mes, true);
     $res = array();
     //獲取的是一個RFID數組
     foreach ($mes as $key => $value) {
         $data = AsAsset::model()->findByPk($value);
         if (is_null($data)) {
             $res[] = array("id" => $value, "name" => 'null', "alarm" => 0);
         } else {
             if ($data['outPrm'] == 'y') {
                 if ($data['state'] == 'out') {
                     // echo "1";
                     $res[] = array("id" => $data['RFID'], "name" => $data['assetName'], "alarm" => 0);
                 } elseif ($data['state'] == 'in') {
                     // echo "2";
                     $res[] = array("id" => $data['RFID'], "name" => $data['assetName'], "alarm" => 1);
                     $mes = "RFID:" . $value . "原因:該商品顯示在庫存中";
                     yii::log($mes, "info", "alarm.log");
                     //將報警信息寫入日誌
                 }
             } else {
                 $mes = "RFID:" . $value . "原因:該商品不允許外借";
                 yii::log($mes, "info", "alarm.log");
                 $res[] = array("id" => $data['RFID'], "name" => $data['assetName'], "alarm" => 1);
             }
         }
     }
     //返回值的形式為RFID,assetName,alarm(1是報警,0是不報警)
     $res1 = json_encode($res);
     echo $res1;
 }
開發者ID:jiahongwei,項目名稱:newland-project,代碼行數:33,代碼來源:AssetAlarmController.php

示例2: changeLogo

 public function changeLogo(CUploadedFile $uploadedFile)
 {
     $basePath = Yii::app()->getModule('cabinet')->getUploadPath();
     //создаем каталог для аватарок, если не существует
     if (!is_dir($basePath) && !@mkdir($basePath, 0755, true)) {
         throw new CException(Yii::t('default', 'It is not possible to create directory for logos!'));
     }
     $filename = $this->id . '_' . time() . '.' . $uploadedFile->extensionName;
     // обновить файл
     //$this->removeOldLogo();
     if (!$uploadedFile->saveAs($basePath . $filename)) {
         throw new CException(Yii::t('default', 'It is not possible to save logos!'));
     }
     // получить запись лого
     $photo = $this->with('photo')->find('photo.id=:id', [':id' => $this->logo_id]);
     $webroot = Yii::getpathOfAlias('webroot');
     $trimPath = str_replace($webroot, '', $basePath);
     $logoFileOld = null;
     $File = new File();
     $File->model = 'Company';
     $File->type = 'image';
     $File->size = filesize($basePath . $filename);
     $File->name = $filename;
     $File->path = $trimPath . $filename;
     $File->record_id = 0;
     if (!is_null($photo['photo'])) {
         $File->id = $photo['photo']['id'];
         $File->isNewRecord = false;
         $logoFileOld = $photo['photo']['path'];
     }
     if ($File->save()) {
         if (0 != strcmp($logoFileOld, $File->path)) {
             @unlink($webroot . $logoFileOld);
         }
     } else {
         yii::log("changeLogo save FAILED id=[" . $File->id . "]", "info");
     }
     if ($this->logo_id != $File->id) {
         // поменять logo_id
         $this->logo_id = $File->id;
         if ($this->validate(['logo_id'])) {
             if (true === $this->update(['logo_id'])) {
             } else {
                 Yii::log("changeLogo update logo_id FAILED", 'info');
             }
         } else {
             Yii::log("changeLogo validate logo_id FAILED", 'info');
         }
     }
     //$this->logo = $filename;
     return true;
 }
開發者ID:alexanderkuz,項目名稱:test-yii2,代碼行數:52,代碼來源:Company.php

示例3: actionReturn

 /**
  * 資產歸還操作
  *
  * @author 張鈺,湯傑
  * @param
  *        	RFID
  * @todo 刪除AsApply表中的相關記錄,添加到AsReturned表中
  */
 public function actionReturn()
 {
     if (XUtils::method() == 'POST' && $_POST['return'] == '確認歸還') {
         $RFID = $_POST['RFID'];
         // var_dump($_POST['RFID']);
         $asset = AsAsset::model()->findByPk($RFID);
         if ($asset['state'] == 'out') {
             $count = AsAsset::model()->updateByPk($RFID, array('state' => 'in'));
             if ($count > 0) {
                 date_default_timezone_set('UTC');
                 $sql = "UPDATE as_borrow SET returnTime=:returnTime WHERE assetID =:assetID";
                 Yii::app()->db->createCommand($sql)->execute(array(':returnTime' => date('Y-m-d'), ':assetID' => $RFID));
                 // $sql = "SELECT * FROM as_borrow WHERE assetID =:assetID";
                 // $data =Yii::app ()->db->createCommand ( $sql )->queryAll();
                 // $data=AsBorrow::model()->findAll("assetID =:assetID",array (":assetID"=>$RFID));
                 $data = AsBorrow::model()->findAll("assetID =:assetID", array(":assetID" => $RFID));
                 $data = json_decode(CJSON::encode($data), TRUE);
                 $mes = "借出號:" . $data[0]['borrowId'] . " 借出人ID:" . $data[0]['userId'] . " 借出人姓名:" . $data[0]['userName'] . " 電話:" . $data[0]['userTeleNum'] . " 資產名稱:" . $data[0]['assetName'] . " 資產ID:" . $data[0]['assetID'] . " 借出時間:" . $data[0]['borrowTime'] . " 歸還時間:" . $data[0]['returnTime'];
                 yii::log($mes, "info", "borrow.log");
                 $analyse = new AsAnalyse();
                 $analyse->assetID = $data[0]['assetID'];
                 $analyse->assetName = $data[0]['assetName'];
                 $analyse->type = $data[0]['type'];
                 $analyse->assetSpecification = $data[0]['assetSpecification'];
                 $analyse->borrowTime = $data[0]['borrowTime'];
                 $analyse->returnTime = $data[0]['returnTime'];
                 // echo var_dump($analyse);
                 if ($analyse->save() > 0) {
                     $sql = "DELETE FROM as_borrow WHERE assetID=:assetID";
                     $data = Yii::app()->db->createCommand($sql)->execute(array(':assetID' => $RFID));
                     //$borrow->updateAll(array('assetID'=>$RFID),'returnTime=:returnTime',array(':returnTime'=> date('Y-m-d')));
                     echo "<script language=\"JavaScript\">alert(\"歸還成功\");</script>";
                 } else {
                     echo "<script language=\"JavaScript\">alert(\"分析記錄失敗\");</script>";
                 }
                 // $sql = "DELETE FROM as_borrow WHERE assetID=:assetID";
                 // $data =Yii::app ()->db->createCommand ( $sql )->execute(array (':assetID' => $RFID));
                 // echo "<script language=\"JavaScript\">alert(\"歸還成功\");</script>";
             } else {
                 echo "<script language=\"JavaScript\">alert(\"歸還失敗\");</script>";
             }
         } else {
             echo "<script language=\"JavaScript\">alert(\"該設備未被借出\");</script>";
         }
     } elseif (XUtils::method() == 'POST' && $_POST['return'] == '查看') {
         $RFID = $_POST['RFID'];
         $sql = "SELECT * FROM as_asset,as_borrow WHERE as_asset.RFID = '" . $RFID . "' and as_borrow.assetID = '" . $RFID . "'";
         // echo $sql;
         $data = Yii::app()->db->createCommand($sql)->queryAll();
         $data = json_decode(CJSON::encode($data), TRUE);
         // var_dump($data);
     }
     $this->render('return', array('RFID' => $_POST['RFID'], 'assetName' => $data[0]['assetName'], 'specification' => $data[0]['specification'], 'inTime' => $data[0]['inTime'], 'storageId' => $data[0]['storageId'], 'price' => $data[0]['Price'], 'name' => $data[0]['userName']));
 }
開發者ID:jiahongwei,項目名稱:newland-project,代碼行數:62,代碼來源:AssetManageController.php


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