去掉输出sql
This commit is contained in:
@@ -26,32 +26,32 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
ActivityRule::observe(ActivityRuleObserver::class);
|
ActivityRule::observe(ActivityRuleObserver::class);
|
||||||
|
|
||||||
\DB::listen(
|
// \DB::listen(
|
||||||
function ($sql) {
|
// function ($sql) {
|
||||||
foreach ($sql->bindings as $i => $binding) {
|
// foreach ($sql->bindings as $i => $binding) {
|
||||||
if ($binding instanceof \DateTime) {
|
// if ($binding instanceof \DateTime) {
|
||||||
$sql->bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
|
// $sql->bindings[$i] = $binding->format('\'Y-m-d H:i:s\'');
|
||||||
} else {
|
// } else {
|
||||||
if (is_string($binding)) {
|
// if (is_string($binding)) {
|
||||||
$sql->bindings[$i] = "'$binding'";
|
// $sql->bindings[$i] = "'$binding'";
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// Insert bindings into query
|
// // Insert bindings into query
|
||||||
$query = str_replace(['%', '?'], ['%%', '%s'], $sql->sql);
|
// $query = str_replace(['%', '?'], ['%%', '%s'], $sql->sql);
|
||||||
|
//
|
||||||
$query = vsprintf($query, $sql->bindings);
|
// $query = vsprintf($query, $sql->bindings);
|
||||||
|
//
|
||||||
// Save the query to file
|
// // Save the query to file
|
||||||
$logFile = fopen(
|
// $logFile = fopen(
|
||||||
storage_path('logs' . DIRECTORY_SEPARATOR . date('Y-m-d') . '_query.log'),
|
// storage_path('logs' . DIRECTORY_SEPARATOR . date('Y-m-d') . '_query.log'),
|
||||||
'a+'
|
// 'a+'
|
||||||
);
|
// );
|
||||||
fwrite($logFile, date('Y-m-d H:i:s') . ': ' . $query . PHP_EOL);
|
// fwrite($logFile, date('Y-m-d H:i:s') . ': ' . $query . PHP_EOL);
|
||||||
fclose($logFile);
|
// fclose($logFile);
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user