mirror of
https://github.com/dg/dibi.git
synced 2025-08-03 20:57:36 +02:00
updated for Nette 2.0 beta
This commit is contained in:
@@ -26,11 +26,11 @@ if (version_compare(PHP_VERSION, '5.2.0', '<')) {
|
|||||||
/**
|
/**
|
||||||
* Compatibility with Nette
|
* Compatibility with Nette
|
||||||
*/
|
*/
|
||||||
if (interface_exists('Nette\\IDebugPanel')) {
|
if (interface_exists('Nette\Diagnostics\IBarPanel')) {
|
||||||
class_alias('Nette\\IDebugPanel', 'IDebugPanel');
|
class_alias('Nette\Diagnostics\IBarPanel', 'IBarPanel');
|
||||||
|
|
||||||
} elseif (!interface_exists('IDebugPanel')) {
|
} elseif (!interface_exists('IBarPanel')) {
|
||||||
interface IDebugPanel {}
|
interface IBarPanel {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -29,7 +29,7 @@ if (!defined('NETTE')) {
|
|||||||
*
|
*
|
||||||
* @author David Grudl
|
* @author David Grudl
|
||||||
*/
|
*/
|
||||||
class DibiException extends Exception implements IDebugPanel
|
class DibiException extends Exception
|
||||||
{
|
{
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $sql;
|
private $sql;
|
||||||
@@ -68,43 +68,6 @@ class DibiException extends Exception implements IDebugPanel
|
|||||||
return parent::__toString() . ($this->sql ? "\nSQL: " . $this->sql : '');
|
return parent::__toString() . ($this->sql ? "\nSQL: " . $this->sql : '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* interface Nette\IDebugPanel ****************d*g**/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns HTML code for custom tab.
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getTab()
|
|
||||||
{
|
|
||||||
return 'SQL';
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns HTML code for custom panel.
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getPanel()
|
|
||||||
{
|
|
||||||
return $this->sql ? dibi::dump($this->sql, TRUE) : NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns panel ID.
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getId()
|
|
||||||
{
|
|
||||||
return __CLASS__;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
*
|
*
|
||||||
* @author David Grudl
|
* @author David Grudl
|
||||||
*/
|
*/
|
||||||
class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
class DibiProfiler extends DibiObject implements IDibiProfiler, IBarPanel
|
||||||
{
|
{
|
||||||
/** maximum number of rows */
|
/** maximum number of rows */
|
||||||
static public $maxQueries = 30;
|
static public $maxQueries = 30;
|
||||||
@@ -52,12 +52,17 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
|||||||
|
|
||||||
public function __construct(array $config)
|
public function __construct(array $config)
|
||||||
{
|
{
|
||||||
if (is_callable('Nette\Debug::addPanel')) {
|
if (is_callable('Nette\Diagnostics\Debugger::enable')) {
|
||||||
call_user_func('Nette\Debug::addPanel', $this);
|
eval('$tmp = Nette\Diagnostics\Debugger::$bar;');
|
||||||
} elseif (is_callable('NDebug::addPanel')) {
|
$tmp->addPanel($this);
|
||||||
NDebug::addPanel($this);
|
eval('$tmp = Nette\Diagnostics\Debugger::$blueScreen;');
|
||||||
} elseif (is_callable('Debug::addPanel')) {
|
$tmp->addPanel(array($this, 'renderException'), __CLASS__);
|
||||||
Debug::addPanel($this);
|
} elseif (is_callable('NDebugger::enable')) {
|
||||||
|
NDebugger::$bar->addPanel($this);
|
||||||
|
NDebugger::$blueScreen->addPanel(array($this, 'renderException'), __CLASS__);
|
||||||
|
} elseif (is_callable('Debugger::enable')) {
|
||||||
|
Debugger::$bar->addPanel($this);
|
||||||
|
Debugger::$blueScreen->addPanel(array($this, 'renderException'), __CLASS__);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->useFirebug = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'FirePHP/');
|
$this->useFirebug = isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'FirePHP/');
|
||||||
@@ -77,6 +82,18 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public function renderException($e)
|
||||||
|
{
|
||||||
|
if ($e instanceof DibiException && $e->getSql()) {
|
||||||
|
return array(
|
||||||
|
'tab' => 'SQL',
|
||||||
|
'panel' => dibi::dump($e->getSql(), TRUE),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string filename
|
* @param string filename
|
||||||
* @return DibiProfiler provides a fluent interface
|
* @return DibiProfiler provides a fluent interface
|
||||||
@@ -242,7 +259,7 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/********************* interface Nette\IDebugPanel ****************d*g**/
|
/********************* interface Nette\Diagnostics\IBarPanel ****************d*g**/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -308,15 +325,4 @@ class DibiProfiler extends DibiObject implements IDibiProfiler, IDebugPanel
|
|||||||
</div>';
|
</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns panel ID.
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public function getId()
|
|
||||||
{
|
|
||||||
return get_class($this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
|||||||
Disallow: /
|
|
@@ -1,8 +1,8 @@
|
|||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>Nette\Debug & SQL Exceptions | dibi</h1>
|
<h1>Nette Debugger & SQL Exceptions | dibi</h1>
|
||||||
|
|
||||||
<p>Dibi can display and log exceptions via Nette\Debug, part of Nette Framework.</p>
|
<p>Dibi can display and log exceptions via Nette Debugger, part of Nette Framework.</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Nette Framework: http://nette.org
|
<li>Nette Framework: http://nette.org
|
||||||
@@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
// enable Nette\Debug
|
// enable Nette Debugger
|
||||||
Debug::enable();
|
Debugger::enable();
|
||||||
|
|
||||||
|
|
||||||
dibi::connect(array(
|
dibi::connect(array(
|
||||||
|
@@ -1,8 +1,8 @@
|
|||||||
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
<!DOCTYPE html><link rel="stylesheet" href="data/style.css">
|
||||||
|
|
||||||
<h1>Nette\Debug & Variables | dibi</h1>
|
<h1>Nette Debugger & Variables | dibi</h1>
|
||||||
|
|
||||||
<p>Dibi can dump variables via Nette\Debug, part of Nette Framework.</p>
|
<p>Dibi can dump variables via Nette Debugger, part of Nette Framework.</p>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li>Nette Framework: http://nette.org
|
<li>Nette Framework: http://nette.org
|
||||||
@@ -10,12 +10,12 @@
|
|||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once 'Nette/Debug.php';
|
require_once 'Nette/Debugger.php';
|
||||||
require_once '../dibi/dibi.php';
|
require_once '../dibi/dibi.php';
|
||||||
|
|
||||||
|
|
||||||
// enable Nette\Debug
|
// enable Nette Debugger
|
||||||
Debug::enable();
|
Debugger::enable();
|
||||||
|
|
||||||
|
|
||||||
dibi::connect(array(
|
dibi::connect(array(
|
||||||
@@ -27,4 +27,4 @@ dibi::connect(array(
|
|||||||
));
|
));
|
||||||
|
|
||||||
|
|
||||||
Debug::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < %i', 38), '[customers]' );
|
Debugger::barDump( dibi::fetchAll('SELECT * FROM customers WHERE customer_id < %i', 38), '[customers]' );
|
||||||
|
Reference in New Issue
Block a user