Beispiel #1
0
 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;
 }
Beispiel #2
0
 /**
  * 返回所有文章
  */
 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);
 }
 /**
  * @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();
 }
 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;
     }
 }
 /**
  * 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);
     }
 }
Beispiel #6
0
 public function query_log()
 {
     return DB::getQueryLog();
 }
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
 /**
  * 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));
     }
 }
Beispiel #10
0
 /**
  * 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();
 }
Beispiel #11
0
 /**
  * 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;
 }