Skip to content

Commit

Permalink
Make hints configurable
Browse files Browse the repository at this point in the history
Enabled by default.
  • Loading branch information
barryvdh committed Oct 31, 2014
1 parent c6c2d07 commit 2459514
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/DataCollector/QueryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class QueryCollector extends PDOCollector
protected $findSource = false;
protected $explainQuery = false;
protected $explainTypes = array('SELECT'); // array('SELECT', 'INSERT', 'UPDATE', 'DELETE'); for MySQL 5.6.3+
protected $showHints = false;

/**
* @param TimeDataCollector $timeCollector
Expand All @@ -26,7 +27,7 @@ public function __construct(TimeDataCollector $timeCollector = null)
}

/**
* Renders the SQL of traced statements with params embeded
* Renders the SQL of traced statements with params embedded
*
* @param boolean $enabled
* @param string $quotationChar NOT USED
Expand All @@ -36,6 +37,16 @@ public function setRenderSqlWithParams($enabled = true, $quotationChar = "'")
$this->renderSqlWithParams = $enabled;
}

/**
* Show or hide the hints in the parameters
*
* @param boolean $enabled
*/
public function setShowHints($enabled = true)
{
$this->showHints = $enabled;
}

/**
* Enable/disable finding the source
*
Expand Down Expand Up @@ -106,7 +117,7 @@ public function addQuery($query, $bindings, $time, $connection)
'time' => $time,
'source' => $source,
'explain' => $explainResults,
'hints' => $hints,
'hints' => $this->showHints ? $hints : null,
);

if ($this->timeCollector !== null) {
Expand Down
4 changes: 4 additions & 0 deletions src/LaravelDebugBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ function ($level, $message, $context) use ($logger) {
$types = $this->app['config']->get('laravel-debugbar::config.options.db.explain.types');
$queryCollector->setExplainSource(true, $types);
}

if ($this->app['config']->get('laravel-debugbar::config.options.db.hints', true)) {
$queryCollector->setShowHints(true);
}

$this->addCollector($queryCollector);

Expand Down
1 change: 1 addition & 0 deletions src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
'enabled' => false,
'types' => array('SELECT'), // array('SELECT', 'INSERT', 'UPDATE', 'DELETE'); for MySQL 5.6.3+
),
'hints' => true, // Show hints for common mistakes
),
'mail' => array(
'full_log' => false
Expand Down

0 comments on commit 2459514

Please sign in to comment.