当前位置: 首页>>代码示例>>PHP>>正文


PHP DB::getQueryLog方法代码示例

本文整理汇总了PHP中DB::getQueryLog方法的典型用法代码示例。如果您正苦于以下问题:PHP DB::getQueryLog方法的具体用法?PHP DB::getQueryLog怎么用?PHP DB::getQueryLog使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DB的用法示例。


在下文中一共展示了DB::getQueryLog方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: index

 public function index($username)
 {
     $user = User::where('first_name', $username)->first();
     var_dump(\DB::getQueryLog());
     var_dump($user);
     return $user->first_name;
 }
开发者ID:Mr-jing,项目名称:imojie,代码行数:7,代码来源:UserController.php

示例2: getExercise

 public function getExercise()
 {
     $json_data = file_get_contents(public_path() . "/js/ejercicio4.json");
     $json = json_decode($json_data);
     DB::transaction(function () use(&$json) {
         $results = DB::select("insert into Exercises (id, description) SELECT COALESCE(MAX(id),0) + 1, 'Interfaz de Constantes' FROM exercises RETURNING id ");
         $exercise_id = $results[0]->id;
         echo $exercise_id;
         $step_number = 0;
         foreach ($json->excercises as $step) {
             $step_number++;
             $results = DB::select("insert into explanations(id, description,exercise_id,step_number,incremental_example,progress) SELECT COALESCE(MAX(id),0) + 1, ?,?,?,?,? FROM explanations RETURNING id ", array($step->explanation, $exercise_id, $step_number, implode("\n", $step->incrementalText), $step->progress));
             $explanation_id = $results[0]->id;
             foreach ($step->answers as $answer) {
                 if (isset($answer->error)) {
                     $error = $answer->error;
                 } else {
                     $error = "";
                 }
                 $description = implode("\n", $answer->text);
                 $correct = $answer->rightAnswer ? 1 : 0;
                 $results = DB::select("insert into answers (id, description,exercise_id,error,correct,step_number) SELECT COALESCE(MAX(id),0) + 1, ?,?,?,?,? FROM answers RETURNING id ", array($description, $exercise_id, $error, $correct, $step_number));
             }
         }
     });
     echo var_dump(DB::getQueryLog());
 }
开发者ID:hugosama1,项目名称:ile,代码行数:27,代码来源:ExerciseController.php

示例3: index

 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $page_title = "Beneficiaries";
     if (Request::wantsJson()) {
         if ($organizationUid = Input::get('org')) {
             $org = $this->org->find($organizationUid);
             $query = $this->model->whereOrganizationId($org->id);
             if (Input::get('past')) {
                 $query = $query->whereHas('campaigns', function ($q) {
                     $q->whereCampaignId($this->campaign->current()->id);
                 }, '=', 0);
                 // i.e. where does NOT have
             } else {
                 $query = $query->whereHas('campaigns', function ($q) {
                     $q->whereCampaignId($this->campaign->current()->id);
                 });
             }
             $beneficiaries = $query->get();
             $beneficiaries = array_map(function ($b) {
                 return ['name' => $b->name, 'logo' => $b->logo, 'url' => $b->url, 'description' => $b->description, 'uid' => $b->uid, 'show_location' => $b->show_location, 'slots_taken' => $b->slots_taken, 'sponsorships_taken' => $b->sponsorships_taken];
             }, $beneficiaries->all());
         } else {
             $beneficiaries = $this->model->with('organization')->get();
             $beneficiaries = array_map(function ($b) {
                 return ['uid' => $b->uid, 'name' => $b->name, 'organization' => $b->organization->name];
             }, $beneficiaries->all());
         }
         return Response::json(['status' => 'success', 'num_queries' => count(\DB::getQueryLog()), 'models' => $beneficiaries]);
     } else {
         return View::make($this->package . '::backend.' . $this->modelName . '.index', ['page_title' => $page_title]);
     }
 }
开发者ID:npmweb,项目名称:service-opportunities,代码行数:37,代码来源:BeneficiariesController.php

示例4: outputData

 /**
  * Outputs gathered data to make Profiler
  *
  * @return html?
  */
 public function outputData()
 {
     // Check if profiler config file is present
     if (\Config::get('profiler::profiler')) {
         // Sort the view data alphabetically
         ksort($this->view_data);
         $this->time->totalTime();
         $data = array('times' => $this->time->getTimes(), 'view_data' => $this->view_data, 'app_logs' => $this->logs, 'includedFiles' => get_included_files(), 'counts' => $this->getCounts(), 'assetPath' => __DIR__ . '/../../../public/');
         // Check if SQL connection can be established
         try {
             $data['sql_log'] = \DB::getQueryLog();
         } catch (\PDOException $exception) {
             $data['sql_log'] = array();
         }
         // Check if btns.storage config option is set
         if (\Config::get('profiler::btns.storage')) {
             // get last 24 webserver log entries
             $data['storageLogs'] = $this->getStorageLogs(24);
         }
         // Check if btns.config config option is set
         if (\Config::get('profiler::btns.config')) {
             // get all Laravel config options and store in array
             $data['config'] = array_dot(\Config::getItems());
         }
         return \View::make('profiler::profiler.core', $data);
     }
 }
开发者ID:seantrane,项目名称:profiler,代码行数:32,代码来源:Profiler.php

示例5: testLists

 public function testLists()
 {
     $lists = Post::where('views', '>=', 10)->lists('id', 'title');
     $debug = last(DB::getQueryLog());
     $this->assertEquals(['Bar' => 2, 'FooBar' => 3], $lists);
     $this->assertEquals('select "id", "title" from "posts" where "published" = ? and "views" >= ? and "status" = ?', $debug['query']);
 }
开发者ID:pixelpeter,项目名称:eloquent-filterable,代码行数:7,代码来源:EloquentFilterTest.php

示例6: last_query

 /**
  * Last query performeds
  *
  * @author Luca Brognara
  * @date Aprile 2015
  *
  * @return void
  */
 public static function last_query()
 {
     $query = DB::getQueryLog();
     $last_query = end($query);
     echo "<pre>";
     print_r($last_query);
     echo "</pre>";
 }
开发者ID:lucabro81,项目名称:edutube,代码行数:16,代码来源:Debug.php

示例7: terminate

 public function terminate($request, $response)
 {
     \Log::debug('=== Start queries ===');
     foreach (\DB::getQueryLog() as $i => $query) {
         \Log::debug("Query #{$i}", ['query' => $query]);
     }
     \Log::debug('=== End queries ===');
 }
开发者ID:BooMamoo,项目名称:angular,代码行数:8,代码来源:QueryLog.php

示例8: update

 /**
  * Updates the selected package.
  *
  * @param $id
  * @param PackageRequest $request
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function update($id, PackageRequest $request)
 {
     $queries = \DB::getQueryLog();
     $package = Package::findOrFail($id);
     $package->update($request->all());
     flash()->message('Successfully updated: ' . $package->name, 'success');
     return redirect()->route('admin.packages.edit', [$package->id]);
 }
开发者ID:jovvybersamin,项目名称:laravel-edronscateringservices,代码行数:15,代码来源:PackageController.php

示例9: index

 public function index($orgPermalink = null)
 {
     $this->dataSource->forOrganization($orgPermalink);
     $rows = $this->dataSource->getData();
     // TODO cache this
     $result = ['datetime' => Carbon::now(), 'opps' => $this->transformer->transformArray($rows)];
     return Response::json(['status' => 'success', 'num_queries' => count(\DB::getQueryLog()), 'time_last_run' => '' . $result['datetime'], 'hostname' => gethostname(), 'models' => $result['opps']]);
 }
开发者ID:npmweb,项目名称:service-opportunities,代码行数:8,代码来源:OpportunityOccurrencesController.php

示例10: test_getAll

 public function test_getAll()
 {
     $items = $this->service->getAll(['columns' => ['id', 'model'], 'page_index' => 1, 'page_size' => 20000, 'includes' => ['productDescriptions'], 'criteria' => []])->getItems();
     $queries = DB::getQueryLog();
     $last_query = end($queries);
     foreach ($items as $item) {
     }
     print_r(json_encode($items, JSON_PRETTY_PRINT));
 }
开发者ID:pda-code,项目名称:eshop-angular-laravel,代码行数:9,代码来源:ProductService_Test.php

示例11: showQuery

function showQuery($last = false)
{
    $queries = DB::getQueryLog();
    if ($last) {
        pr(end($queries));
    } else {
        pr($queries);
    }
}
开发者ID:nguyendaivu,项目名称:imagestock,代码行数:9,代码来源:ultility.php

示例12: test_query

 public function test_query()
 {
     $items = Category::select('c.category_id', 'c.parent_id', 'cd.name', DB::raw('(SELECT count(category_id) FROM oc_category) AS childrenCount'))->from('oc_category as c')->where('c.parent_id', 0)->where('cd.language_id', 1)->join('oc_category_description as cd', 'c.category_id', '=', 'cd.category_id')->orderBy('c.sort_order')->get();
     $queries = DB::getQueryLog();
     $last_query = end($queries);
     var_dump($last_query['query']);
     var_dump(count($items));
     var_dump($items->count());
     $this->assertNotNull($items->count());
 }
开发者ID:pda-code,项目名称:eshop-angular-laravel,代码行数:10,代码来源:CatalogService_Test.php

示例13: outputData

 /**
  * Outputs gathered data to make Profiler
  *
  * @return html?
  */
 public function outputData()
 {
     if (\Config::get('omni::profiler')) {
         // Sort the view data alphabetically
         ksort($this->view_data);
         $this->time->totalTime();
         $data = array('times' => $this->time->getTimes(), 'view_data' => $this->view_data, 'sql_log' => array_reverse(\DB::getQueryLog()), 'app_logs' => $this->logs);
         return \View::make('omni::profiler.core', $data);
     }
 }
开发者ID:sorora,项目名称:omni,代码行数:15,代码来源:Omni.php

示例14: queryLog

 public static function queryLog($queryLog = null)
 {
     if (is_null($queryLog)) {
         $queryLog = \DB::getQueryLog();
     }
     $queryString = "";
     foreach ($queryLog as $i => $query) {
         $queryString .= "#{$i} " . L4ToString::query($query['query'], $query['bindings'], $query['time']) . "\n";
     }
     return $queryString;
 }
开发者ID:xethron,项目名称:l4-to-string,代码行数:11,代码来源:L4ToString.php

示例15: terminate

 public function terminate($request, $response)
 {
     if (!\App::runningInConsole() && \App::bound('veer') && app('veer')->isBooted()) {
         $timeToLoad = empty(app('veer')->statistics['loading']) ? 0 : app('veer')->statistics['loading'];
         if ($timeToLoad > config('veer.loadingtime')) {
             \Log::alert('Slowness detected: ' . $timeToLoad . ': ', app('veer')->statistics());
             info('Queries: ', \DB::getQueryLog());
         }
         \Veer\Jobs\TrackingUser::run();
         (new \Veer\Commands\HttpQueueWorkerCommand(config('queue.default')))->handle();
     }
 }
开发者ID:artemsk,项目名称:veer-core,代码行数:12,代码来源:ShutdownMiddleware.php


注:本文中的DB::getQueryLog方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。