mirror of
https://github.com/dg/dibi.git
synced 2025-07-31 19:30:30 +02:00
examples: improved Tracy examples
This commit is contained in:
@@ -2,11 +2,7 @@
|
|||||||
|
|
||||||
<h1>Tracy & SQL Exceptions | dibi</h1>
|
<h1>Tracy & SQL Exceptions | dibi</h1>
|
||||||
|
|
||||||
<p>Dibi can display and log exceptions via Tracy, part of Nette Framework.</p>
|
<p>Dibi can display and log exceptions via <a href="http://tracy.nette.org">Tracy</a>.</p>
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Tracy Debugger: http://tracy.nette.org
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
@@ -15,10 +11,11 @@ if (@!include __DIR__ . '/../vendor/autoload.php') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// enable Tracy
|
||||||
Tracy\Debugger::enable();
|
Tracy\Debugger::enable();
|
||||||
|
|
||||||
|
|
||||||
dibi::connect(array(
|
$connection = dibi::connect(array(
|
||||||
'driver' => 'sqlite3',
|
'driver' => 'sqlite3',
|
||||||
'database' => 'data/sample.s3db',
|
'database' => 'data/sample.s3db',
|
||||||
'profiler' => array(
|
'profiler' => array(
|
||||||
@@ -27,17 +24,9 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
// throws error because SQL is bad
|
// add panel to debug bar
|
||||||
dibi::query('SELECT * FROM customers WHERE customer_id < ?', 38);
|
$panel = new Dibi\Bridges\Tracy\Panel;
|
||||||
|
$panel->register($connection);
|
||||||
|
|
||||||
dibi::connect(array(
|
|
||||||
'driver' => 'sqlite3',
|
|
||||||
'database' => 'data/sample.s3db',
|
|
||||||
'profiler' => array(
|
|
||||||
'run' => TRUE,
|
|
||||||
)
|
|
||||||
));
|
|
||||||
|
|
||||||
|
|
||||||
// throws error because SQL is bad
|
// throws error because SQL is bad
|
||||||
|
@@ -2,13 +2,9 @@
|
|||||||
|
|
||||||
<style> html { background: url(data/arrow.png) no-repeat bottom right; height: 100%; } </style>
|
<style> html { background: url(data/arrow.png) no-repeat bottom right; height: 100%; } </style>
|
||||||
|
|
||||||
<h1>Tracy & Variables | dibi</h1>
|
<h1>Tracy | dibi</h1>
|
||||||
|
|
||||||
<p>Dibi can dump variables via Tracy, part of Nette Framework.</p>
|
<p>Dibi can log queries and dump variables to the <a href="http://tracy.nette.org">Tracy</a>.</p>
|
||||||
|
|
||||||
<ul>
|
|
||||||
<li>Tracy Debugger: http://tracy.nette.org
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
@@ -17,10 +13,11 @@ if (@!include __DIR__ . '/../vendor/autoload.php') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// enable Tracy
|
||||||
Tracy\Debugger::enable();
|
Tracy\Debugger::enable();
|
||||||
|
|
||||||
|
|
||||||
dibi::connect(array(
|
$connection = dibi::connect(array(
|
||||||
'driver' => 'sqlite3',
|
'driver' => 'sqlite3',
|
||||||
'database' => 'data/sample.s3db',
|
'database' => 'data/sample.s3db',
|
||||||
'profiler' => array(
|
'profiler' => array(
|
||||||
@@ -29,4 +26,13 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
|
// 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
|
||||||
Tracy\Debugger::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]' );
|
Tracy\Debugger::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < ?', 38), '[customers]' );
|
Reference in New Issue
Block a user