当前位置: 首页>>代码示例>>PHP>>正文


PHP DB::disableQueryLog方法代码示例

本文整理汇总了PHP中App\Http\Controllers\DB::disableQueryLog方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::disableQueryLog方法的具体用法?PHP DB::disableQueryLog怎么用?PHP DB::disableQueryLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App\Http\Controllers\DB的用法示例。


在下文中一共展示了DB::disableQueryLog方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run


//.........这里部分代码省略.........
     		$d1 = floor($d1/(60*60*24));
     		$d2 = strtotime($date_to) - strtotime($date_begin);
     		$d2 = floor($d2/(60*60*24)); */
     $d1 = $date_from->timestamp - $date_begin->timestamp;
     $d1 = floor($d1 / (60 * 60 * 24));
     $d2 = $date_to->timestamp - $date_begin->timestamp;
     $d2 = floor($d2 / (60 * 60 * 24));
     $timeForecast = "";
     for ($i = $d1; $i < $d2 + 1; $i++) {
         $timeForecast .= ($timeForecast ? "\r\n" : "") . $i;
         if ($lastT && $i - $lastT != 1 && $continous) {
             $continous = false;
         }
         $lastT = $i;
     }
     $sqls = [];
     $warning = '';
     if (!$continous) {
         $warning = "Timing is not continuous";
     }
     file_put_contents("t{$mkey}.txt", $timeForecast);
     // 		echo "<b>Time forecast:</b> ".$timeForecast."<br>";
     if ($a === "0" || $a === "1") {
         $params = "{$a},{$b},0,0,0,0,0";
     } else {
         if ($c2 > 0) {
             $params = "{$a},{$b},0,0,0,{$c1},{$c2}";
         } else {
             $params = "{$a},{$b},{$l},{$u},{$m},{$c1},0";
         }
     }
     file_put_contents("prop{$mkey}.txt", $params);
     $error = [];
     $results = [];
     if (!file_exists('pdforecast.exe')) {
         $error[] = "Exec file not found";
     } else {
         if (file_exists("data{$mkey}.txt") && file_exists("t{$mkey}.txt") && file_exists("prop{$mkey}.txt")) {
             set_time_limit(300);
             exec("pdforecast.exe {$mkey}");
             if (file_exists("error{$mkey}.txt")) {
                 $error[] = file_get_contents("error{$mkey}.txt", true);
             }
             if (file_exists("forecast_q{$mkey}.csv")) {
                 // 					echo "<b>Result:</b><br>";
                 $file = fopen("forecast_q{$mkey}.csv", "r");
                 $configuration = auth()->user()->getConfiguration();
                 $format = $configuration['time']['DATE_FORMAT_CARBON'];
                 //'m/d/Y';
                 while (!feof($file)) {
                     $line = fgets($file);
                     // 						echo $line;
                     // 						$result.= $line;
                     $result = ['value' => $line];
                     if ($line) {
                         $xs = explode(",", $line);
                         if (count($xs >= 2)) {
                             $x_time = trim($xs[0]);
                             $x_value = trim($xs[1]);
                             if ($x_time >= $d1) {
                                 // 									$x_time=($x_time)*60*60*24+strtotime($date_begin);
                                 $beginTimeStamp = $date_begin->timestamp;
                                 $x_time = $x_time * 60 * 60 * 24 + $beginTimeStamp;
                                 // 									$x_date=date('Y-m-d',$x_time);
                                 $x_date = Carbon::createFromTimestamp($x_time);
                                 //     								$x_date		= 	$x_date->createFromTimestamp($x_time);
                                 // 									echo " ($x_date) ";
                                 $rxDate = $x_date ? $x_date->format($format) : $x_date;
                                 //     								$result.= " ($rxDate) ";
                                 $result['date'] = $rxDate;
                                 if ($cb_update_db == 'true') {
                                     $field = "EU_DATA_{$value_type}";
                                     $field = strtoupper($field);
                                     $attributes = ['EU_ID' => $object_id, 'OCCUR_DATE' => $x_date, "FLOW_PHASE" => $phase_type];
                                     $values = ['EU_ID' => $object_id, 'OCCUR_DATE' => $x_date, "FLOW_PHASE" => $phase_type, $field => $x_value];
                                     \DB::enableQueryLog();
                                     EnergyUnitDataForecast::updateOrCreate($attributes, $values);
                                     $result['sql'] = \Helper::logger();
                                 }
                             }
                         }
                     }
                     $results[] = $result;
                     // 						echo "<br>";
                 }
                 \DB::disableQueryLog();
                 fclose($file);
             } else {
                 // 					logError("Result file not found");
                 $error[] = "Result file not found";
             }
         } else {
             // 				logError("Input files not found");
             $error[] = "Input files not found";
         }
     }
     $finalResults = ['data' => $data, 'warning' => $warning, 'params' => $params, 'time' => $timeForecast, 'result' => $results, 'error' => $error, 'key' => $mkey];
     $this->cleanFiles($mkey);
     return response()->json($finalResults);
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:101,代码来源:EnergyUnitForecastController.php

示例2: run


//.........这里部分代码省略.........
     }
     //['error'=>"empty input data"];
     $ele = array_values($objdata)[0];
     $data = "";
     $inputData = [];
     foreach ($ele as $key => $value) {
         $ss = [];
         foreach ($objdata as $source => $objValue) {
             if ($objValue[$key] !== "") {
                 $ss[] = $objValue[$key];
                 $inputData[] = $objValue[$key] . " <- [{$source}][{$key}]";
             }
         }
         if (count($ss) > 0) {
             $data .= ($data ? "\r\n" : "") . implode(",", $ss);
         }
     }
     file_put_contents($files['data'], $data);
     $error = [];
     $results = [];
     $sqls = [];
     //Gas
     $exe = $phase_type == 2 ? $files['gas'] : $files['oil'];
     if (!file_exists($exe)) {
         $error[] = "Exec {$exe} file not found";
     } else {
         if (file_exists($files['data'])) {
             set_time_limit(300);
             exec("{$exe} {$mkey}");
             if (file_exists($files['error'])) {
                 $error[] = file_get_contents($files['error'], true);
             }
             if (file_exists($files['PR_single_V'])) {
                 $fileName = $files['PR_single_V'];
                 $file = fopen($fileName, "r");
                 $lastline = "";
                 $result = [];
                 while (!feof($file)) {
                     $line = fgets($file);
                     $result[] = $line;
                     if ($line) {
                         if ($line) {
                             $lastline = $line;
                         }
                     }
                 }
                 $results[$fileName] = $result;
                 fclose($file);
                 $fileName = $files['PR_single_L'];
                 $file = fopen($fileName, "r");
                 $lastline = "";
                 $result = [];
                 while (!feof($file)) {
                     $line = fgets($file);
                     $result[] = $line;
                     if ($line) {
                         if ($line) {
                             $lastline = $line;
                         }
                     }
                 }
                 $results[$fileName] = $result;
                 fclose($file);
                 if ($lastline && $cb_update_db == 'true') {
                     $xs = explode(",", $lastline);
                     $i = 0;
                     foreach ($xs as $svol) {
                         if ($i < count($objinfo)) {
                             $src = $objinfo[$i]["src"];
                             $pre = $objinfo[$i]["pre"];
                             $table = $src . "_DATA_VALUE";
                             $field = $pre . "_DATA_{$value_type}";
                             $field = strtoupper($field);
                             $attributes = ["OCCUR_DATE" => $occur_date];
                             if ($src == "ENERGY_UNIT") {
                                 $attributes['FLOW_PHASE'] = $phase_type;
                             }
                             $attributes["{$pre}" . "_ID"] = $objinfo[$i]["obj_id"];
                             $values = $attributes;
                             $values[$field] = $svol;
                             $mdl = \Helper::getModelName($table);
                             \DB::enableQueryLog();
                             $mdl::updateOrCreate($attributes, $values);
                             $sqls[] = \Helper::logger();
                         }
                         $i++;
                     }
                     \DB::disableQueryLog();
                 }
             } else {
                 $error[] = "Result file not found";
             }
         } else {
             $error[] = "Input files not found";
         }
     }
     $finalResults = ['data' => $inputData, 'warning' => '', 'result' => $results, 'error' => $error, 'key' => $mkey, 'exe' => $exe, 'sqls' => $sqls];
     // 		$this->cleanFiles($mkey);
     return response()->json($finalResults);
 }
开发者ID:hunglmtb,项目名称:eb,代码行数:101,代码来源:PreosController.php


注:本文中的App\Http\Controllers\DB::disableQueryLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。