本文整理汇总了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;
}
示例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());
}
示例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]);
}
}
示例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);
}
}
示例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']);
}
示例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>";
}
示例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 ===');
}
示例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]);
}
示例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']]);
}
示例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));
}
示例11: showQuery
function showQuery($last = false)
{
$queries = DB::getQueryLog();
if ($last) {
pr(end($queries));
} else {
pr($queries);
}
}
示例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());
}
示例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);
}
}
示例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;
}
示例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();
}
}