本文整理汇总了PHP中Illuminate\Support\Facades\DB::getQueryLog方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getQueryLog方法的具体用法?PHP DB::getQueryLog怎么用?PHP DB::getQueryLog使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Support\Facades\DB
的用法示例。
在下文中一共展示了DB::getQueryLog方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getCities
static function getCities($regionId, $countryId = "IN")
{
$cities = Cities::where('country', '=', $countryId)->where('region', '=', $regionId)->lists('name', 'ID');
$queries = DB::getQueryLog();
/* print_R($queries);
dd($cities); */
return $cities;
}
示例2: GetAllPost
/**
* 返回所有文章
*/
function GetAllPost(Request $request)
{
DB::connection()->enableQueryLog();
$postSrv = new Post();
$res = $postSrv->GetAllPost($request->all());
$res['success'] = $res['data'] ? true : false;
$res['sql'] = DB::getQueryLog();
return json_encode($res, JSON_UNESCAPED_UNICODE);
}
示例3:
/**
* @param CachingRepositoryInterface $repository
*/
function check_caching_repository_caching(CachingRepositoryInterface $repository)
{
DB::enableQueryLog();
$this->assertCount(8, $repository->inProgress()->get());
$this->assertCount(10, $repository->completed()->get());
$this->assertCount(2, DB::getQueryLog());
$this->assertCount(8, $repository->inProgress()->get());
$this->assertCount(10, $repository->completed()->get());
$this->assertCount(2, DB::getQueryLog());
$this->assertCount(18, $repository->all());
$this->assertCount(3, DB::getQueryLog());
$this->assertCount(18, $repository->all());
$this->assertCount(3, DB::getQueryLog());
DB::disableQueryLog();
\Cache::flush();
}
示例4: buildTree
private function buildTree($parent_id, &$container, $level, $max_level, $include_children_count, $include_products_count)
{
if ($level > $max_level) {
return;
}
$select = array('c.id', 'c.parent_id', 'cd.name');
$query = $this->buildQuery($include_children_count, $include_products_count);
$query->where('c.parent_id', $parent_id);
$items = $query->get();
$queries = DB::getQueryLog();
$last_query = end($queries)['query'];
foreach ($items as $item) {
$item->level = $level;
$children = array();
$this->buildTree($item->id, $children, $level + 1, $max_level, $include_children_count, $include_products_count);
$item->children = $children;
$container[] = $item;
}
}
示例5: output
/**
* Prints output
*
* @return null
*/
private function output($raw = false)
{
$sColumns = array_merge_recursive($this->columns, $this->sColumns);
$output = array("sEcho" => intval(Input::get('sEcho')), "iTotalRecords" => $this->count_all, "iTotalDisplayRecords" => $this->display_all, "aaData" => $this->result_array_r, "sColumns" => $sColumns);
if (Config::get('app.debug', false)) {
$output['aQueries'] = DB::getQueryLog();
}
if ($raw) {
return $output;
} else {
return Response::json($output);
}
}
示例6: query_log
public function query_log()
{
return DB::getQueryLog();
}
示例7: output
/**
* Prints output
*
* @param bool $raw If raw will output array data, otherwise json
*
* @return array|json
*/
protected function output($raw = false)
{
if (Arr::get($this->input, 'version') == '1.10') {
$output = array("draw" => intval($this->input['draw']), "recordsTotal" => $this->count_all, "recordsFiltered" => $this->display_all, "data" => $this->result_array_return);
} else {
$sColumns = array_merge_recursive($this->columns, $this->sColumns);
$output = array("sEcho" => intval($this->input['draw']), "iTotalRecords" => $this->count_all, "iTotalDisplayRecords" => $this->display_all, "aaData" => $this->result_array_return, "sColumns" => $sColumns);
}
if (Config::get('app.debug', false)) {
$output['aQueries'] = DB::getQueryLog();
}
if ($raw) {
return $output;
} else {
return Response::json($output);
}
}
示例8: verbose
/**
* Added the raw information from the game server. Used for debugging only.
*
* @return $this
*/
private function verbose()
{
$serverinfo = $this->serverinfo;
$this->data['_raw']['playerlist'] = $this->client->adminGetPlayerlist();
for ($i = 0; $i < count($serverinfo); $i++) {
$key = 'K' . $i;
$this->data['_raw']['serverinfo'][$key] = $serverinfo[$i];
if (is_numeric($this->data['_raw']['serverinfo'][$key])) {
$this->data['_raw']['serverinfo'][$key] = intval($this->data['_raw']['serverinfo'][$key]);
} else {
if ($this->data['_raw']['serverinfo'][$key] == 'true' || $this->data['_raw']['serverinfo'][$key] == 'false') {
$this->data['_raw']['serverinfo'][$key] = $this->data['_raw']['serverinfo'][$key] == 'true' ? true : false;
}
}
}
$this->data['_raw']['sql_time'] = 0;
$this->data['_raw']['sql'] = DB::getQueryLog();
foreach ($this->data['_raw']['sql'] as $sql) {
$this->data['_raw']['sql_time'] = $this->data['_raw']['sql_time'] + $sql['time'];
}
return $this;
}
示例9: logSqlQueries
/**
* Log all executed queries into the log file.
*/
protected function logSqlQueries()
{
if (!$this->isDebug()) {
return;
}
$queries = DB::getQueryLog();
foreach ($queries as $query) {
$this->getLogger()->addInfo(json_encode($query));
}
}
示例10: inspect
/**
* Inspect a route.
*
* @param Client $client
* @param string $route
*/
protected function inspect(Client $client, $route)
{
try {
$this->info('Inspecting ' . $route);
$client->request('GET', $route);
} catch (Exception $exception) {
$this->error('Error inspecting ' . $route);
}
// Format and sort queries
$routeQueries = DB::getQueryLog();
$routeQueries = array_pluck($routeQueries, 'query');
sort($routeQueries);
// Cancel if no queries on this page
if (empty($routeQueries)) {
return;
}
// Store and flush
$this->queries[$route]['response'] = $client->getResponse()->getContent();
$this->queries[$route]['queries'] = $routeQueries;
DB::flushQueryLog();
}
示例11: statistics
/**
* Collecting statistics.
*
*
*/
public function statistics()
{
$this->statistics['queries'] = count(\Illuminate\Support\Facades\DB::getQueryLog());
$this->statistics['loading'] = round(microtime(true) - LARAVEL_START, 4);
$this->statistics['memory'] = number_format(memory_get_usage());
$this->statistics['version'] = self::VEERVERSION;
return $this->statistics;
}