本文整理汇总了PHP中App\Http\Controllers\DB::enableQueryLog方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::enableQueryLog方法的具体用法?PHP DB::enableQueryLog怎么用?PHP DB::enableQueryLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\DB
的用法示例。
在下文中一共展示了DB::enableQueryLog方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
$this->manager = new Manager();
if ($include = Request::get('include')) {
$this->manager->parseIncludes($include);
}
$this->serializer = Request::get('serializer') ?: API_SERIALIZER_ARRAY;
if ($this->serializer === API_SERIALIZER_JSON) {
$this->manager->setSerializer(new JsonApiSerializer());
} else {
$this->manager->setSerializer(new ArraySerializer());
}
if (Utils::isNinjaDev()) {
\DB::enableQueryLog();
}
}
示例2: 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);
}
示例3: run
public function run(Request $request)
{
$postData = $request->all();
$phase_type = $postData['ExtensionPhaseType'];
$cb_update_db = $postData['cb_update_db'];
$occur_date = $postData['date_begin'];
$value_type = $postData['ExtensionValueType'];
$occur_date = \Helper::parseDate($occur_date);
$inputDataSet = $this->getInputDataSet($postData, $occur_date);
$objdata = $inputDataSet['data'];
$objinfo = $inputDataSet['info'];
$mkey = "";
// $mkey = "_".date("Ymdhis_").rand(100,1000)/* ."hung_test" */;
$preos = "";
$files = ['gas' => "{$preos}" . "prvap.exe", 'oil' => "{$preos}" . "prliq.exe", 'data' => "{$preos}" . "data{$mkey}.txt", 'm_ij' => "{$preos}" . "m_ij{$mkey}.txt", 'prop' => "{$preos}" . "prop{$mkey}.txt", 'error' => "{$preos}" . "error{$mkey}.txt", 'PR_single_V' => "{$preos}" . "PR_single_V{$mkey}.csv", 'PR_single_L' => "{$preos}" . "PR_single_L{$mkey}.csv"];
$cc = count($objdata);
if ($cc <= 0) {
return response('empty input data', 401);
}
//['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();
//.........这里部分代码省略.........
示例4: getSuggestions
/**
* To get the products suggestion, taking in account either the preference key, such as
* (product_viewed, product_purchased, product_shared, product_categories, my_searches), or all of them.
*
* @param [array] $data, which is the suggest configuration
*
* @return [array] $products, which will contain all the suggestion for the user either in session or suggested
*/
public static function getSuggestions($data)
{
$options = ['user_id' => '', 'preferences_key' => '', 'limit' => '4', 'category' => '', 'select' => '*'];
$suggest_listed = Session::get('suggest-listed');
if (count($suggest_listed)) {
$suggest_listed = array_unique($suggest_listed);
} else {
$suggest_listed = [];
}
$data = $data + $options;
$diff = 0;
$productsHelper = new ProductsHelper();
$needle['tags'] = [];
// the suggestions based on one id (one product)
if (is_int($data['preferences_key'])) {
$data['preferences_key'] = [$data['preferences_key']];
}
// the suggestions based on a list of products
if (is_array($data['preferences_key'])) {
foreach ($data['preferences_key'] as $id) {
$needleAux = Product::select('tags', 'name')->where('id', $id)->free()->orderBy('rate_count', 'desc')->first()->toArray();
//extraction of tags and name of products
$needle['tags'] = array_merge($needle['tags'], explode(',', trim($needleAux['tags'])), explode(' ', trim($needleAux['name'])));
}
} else {
$needle = UserController::getPreferences($data['preferences_key']);
//getting the user preferences
}
if (count($needle['tags']) > 0) {
//by preferences
if ($data['preferences_key'] == 'product_categories') {
//look up by categories. If we want to get a specific category, we have to add "category" to data array
\DB::enableQueryLog();
$products[0] = Product::select($data['select'])->free()->whereNotIn('id', $suggest_listed)->inCategories('category_id', $needle['tags'])->orderBy('rate_count', 'desc')->take($data['limit'])->get()->toArray();
} else {
//look up by products tags and name
$products[0] = Product::select($data['select'])->free()->whereNotIn('id', $suggest_listed)->like(['tags', 'name'], $needle['tags'])->orderBy('rate_count', 'desc')->take($data['limit'])->get()->toArray();
}
}
$diff = $data['limit'] - (isset($products[0]) ? count($products[0]) : 0);
//limit control
//if we get suggestion results, we save those id
if (isset($products[0])) {
$productsHelper->setToHaystack($products[0]);
}
//by rate
if ($diff > 0 && $diff <= $data['limit']) {
$products[1] = Product::select($data['select'])->where($productsHelper->getFieldToSuggestions($data['preferences_key']), '>', '0')->whereNotIn('id', $suggest_listed)->free()->orderBy($productsHelper->getFieldToSuggestions($data['preferences_key']), 'DESC')->take($diff)->get()->toArray();
$diff = $diff - count($products[1]);
//limit control
}
//if we get suggestion results, we save those id
if (isset($products[1])) {
$productsHelper->setToHaystack($products[1]);
}
//by rand
if ($diff > 0 && $diff <= $data['limit']) {
$products[2] = Product::select($data['select'])->free()->whereNotIn('id', $suggest_listed)->orderByRaw('RAND()')->take($diff)->get()->toArray();
}
//if we get suggestion results, we save those id
if (isset($products[2])) {
$productsHelper->setToHaystack($products[2]);
}
//making one array to return
$array = [];
$products = array_values($products);
for ($i = 0; $i < count($products); $i++) {
if (count($products[$i]) > 0) {
$array = array_merge($array, $products[$i]);
}
}
return $array;
}
示例5: __construct
public function __construct()
{
\DB::enableQueryLog();
}
示例6: testPermissions
public function testPermissions()
{
\DB::enableQueryLog();
$user = \Auth::user();
// $role = Role::create(['name' => 'test', 'slug' => 'test', 'description' => 'test']);
// $user->assignRole(Role::where('slug', 'test')->first());
// $user->revokeRole($role = Role::where('slug', 'test')->first());
// $role->delete();
dd([$user->getPermissions(), \DB::getQueryLog()]);
}