using-profiler.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <?php ob_start() // needed by FirePHP ?>
  2. <!DOCTYPE html><link rel="stylesheet" href="data/style.css">
  3. <h1>Using Profiler | dibi</h1>
  4. <?php
  5. require __DIR__ . '/../src/loader.php';
  6. dibi::connect([
  7. 'driver' => 'sqlite3',
  8. 'database' => 'data/sample.s3db',
  9. 'profiler' => [
  10. 'run' => true,
  11. ],
  12. ]);
  13. // execute some queries...
  14. for ($i = 0; $i < 20; $i++) {
  15. $res = dibi::query('SELECT * FROM [customers] WHERE [customer_id] < ?', $i);
  16. }
  17. // display output
  18. ?>
  19. <p>Last query: <strong><?php echo dibi::$sql; ?></strong></p>
  20. <p>Number of queries: <strong><?php echo dibi::$numOfQueries; ?></strong></p>
  21. <p>Elapsed time for last query: <strong><?php echo sprintf('%0.3f', dibi::$elapsedTime * 1000); ?> ms</strong></p>
  22. <p>Total elapsed time: <strong><?php echo sprintf('%0.3f', dibi::$totalTime * 1000); ?> ms</strong></p>
  23. <br>
  24. <p>Dibi can log to your Firebug Console. You first need to install the Firefox, Firebug and FirePHP extensions. You can install them from here:</p>
  25. <ul>
  26. <li>Firebug: https://addons.mozilla.org/en-US/firefox/addon/1843
  27. <li>FirePHP: http://www.firephp.org/
  28. </ul>