本文整理汇总了PHP中App\Http\Controllers\DB::getQueryLog方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getQueryLog方法的具体用法?PHP DB::getQueryLog怎么用?PHP DB::getQueryLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\DB
的用法示例。
在下文中一共展示了DB::getQueryLog方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
public function index()
{
$name = "Ivan";
$age = $_GET['age'];
$results = DB::getQueryLog();
var_dump($results);
exit;
return view("sites.sites")->with("name", $name)->with("age", $age);
}
示例2: printRawSql
/**
* 打印原生态sql
* @access protected
* @param boolean $needLog 是否要记录日志
* @return array
*/
protected function printRawSql($needLog = false)
{
$queries = \DB::getQueryLog();
$formattedQueries = [];
foreach ($queries as $query) {
$prep = $query['query'];
foreach ($query['bindings'] as $binding) {
$prep = preg_replace("#\\?#", $binding, $prep, 1);
}
$formattedQueries[] = $prep;
}
if ($needLog) {
\Log::info($formattedQueries);
}
return $formattedQueries;
}
示例3: response
protected function response($response)
{
if (Utils::isNinjaDev()) {
$count = count(\DB::getQueryLog());
Log::info(Request::method() . ' - ' . Request::url() . ": {$count} queries");
Log::info(json_encode(\DB::getQueryLog()));
}
$index = Request::get('index') ?: 'data';
if ($index == 'none') {
unset($response['meta']);
} else {
$meta = isset($response['meta']) ? $response['meta'] : null;
$response = [$index => $response];
if ($meta) {
$response['meta'] = $meta;
unset($response[$index]['meta']);
}
}
$response = json_encode($response, JSON_PRETTY_PRINT);
$headers = Utils::getApiHeaders();
return Response::make($response, 200, $headers);
}
示例4: 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()]);
}