1
0
mirror of https://github.com/dg/dibi.git synced 2025-02-22 01:48:05 +01:00
php-dibi/examples/tracy.php

39 lines
872 B
PHP
Raw Normal View History

<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
<style> html { background: url(data/arrow.png) no-repeat bottom right; height: 100%; } </style>
2015-01-10 19:03:16 +01:00
<h1>Tracy | dibi</h1>
2015-10-05 16:14:16 +02:00
<p>Dibi can log queries and dump variables to the <a href="https://tracy.nette.org">Tracy</a>.</p>
<?php
if (@!include __DIR__ . '/../vendor/autoload.php') {
die('Install dependencies using `composer install --dev`');
}
2015-01-10 19:03:16 +01:00
// enable Tracy
Tracy\Debugger::enable();
2015-10-06 01:39:01 +02:00
$connection = dibi::connect([
2015-06-19 03:11:36 +02:00
'driver' => 'sqlite3',
'database' => 'data/sample.s3db',
2015-10-06 01:39:01 +02:00
'profiler' => [
'run' => TRUE,
2015-10-06 01:39:01 +02:00
],
]);
2015-01-10 19:03:16 +01:00
// add panel to debug bar
$panel = new Dibi\Bridges\Tracy\Panel;
$panel->register($connection);
// query will be logged
dibi::query('SELECT 123');
// result set will be dumped
2015-06-19 03:11:36 +02:00
Tracy\Debugger::barDump(dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]');