本文整理汇总了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;
}
示例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;
}
示例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']));
}