yii2 日志
php笔记
0 302
/** * @param $data 数组 * @return void * @throws \yii\base\InvalidConfigException * @throws \yii\log\LogRuntimeException * 写入日志 */function writeLog($data$type=0){ $log = new yii\log\FileTarget(); $file = 'app.log'; if ($type == 1) { $file = 'curtain.log'; } $log->logFile = Yii::$app->getRuntimePath() . '/logs/' . date("Ymd") . $file; if (is_array($data)) { $data = json_encode($data JSON_UNESCAPED_UNICODE); } $log->messages[] = [$data 1 'application' time()]; $log->export();}
writeLog(['自动转单'=>$orderList]);
writeLog(['自动转单Sql'=>ddSql((new \yii\db\Query()) ->from('{{%chaopin_takeout_order}}') ->where(['in''state'[12]]) ->andWhere(['orderPid'=>null]) ->andWhere(['>=''otherInfotime'$starttime]) ->andWhere(['<=''otherInfotime'$dqsj]))]);
//打印sql数据function ddSql($sql){ $newSql = $sql->createCommand()->getRawSql(); return $newSql;}
发表评论