forked from propelorm/sfPropelORMPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable to show the explanation for a query in the symfony debug bar
Add a module to run explain Add a link to show the explain Require the following config in databases.yml : dev: propel: param: debug: realmemoryusage: true details: connection: { enabled: true }
- Loading branch information
1 parent
8709ee5
commit 22273c9
Showing
5 changed files
with
104 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
propel_debug_pannel: | ||
url: /propel-debug-pannel/:connection/:base64_query | ||
param: { module: sfPropelORMExplain, action: index } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
class sfPropelORMExplainActions extends sfActions | ||
{ | ||
public function executeIndex(sfWebRequest $request) | ||
{ | ||
$this->setLayout(false); | ||
sfConfig::set('sf_web_debug', false); | ||
|
||
// Open the connection | ||
$con = \Propel::getConnection($request->getParameter('connection')); | ||
|
||
// Get the adapter | ||
$db = \Propel::getDB($request->getParameter('connection')); | ||
|
||
try { | ||
$this->query = base64_decode($request->getParameter('base64_query')); | ||
$stmt = $db->doExplainPlan($con, $this->query); | ||
$this->results = $stmt->fetchAll(\PDO::FETCH_ASSOC); | ||
} catch (Exception $e) { | ||
$this->getResponse()->setContent('<div class="error">This query cannot be explained.</div>'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<h2>Explanation</h2> | ||
|
||
<table> | ||
<tr> | ||
<?php foreach($results[0] as $label =>$val): ?> | ||
<th><?php echo $label; ?></th> | ||
<?php endforeach; ?> | ||
</tr> | ||
<?php foreach($results as $row): ?> | ||
<tr> | ||
<?php foreach($row as $item): ?> | ||
<td><?php echo $item; ?></td> | ||
<?php endforeach; ?> | ||
</tr> | ||
<?php endforeach; ?> | ||
</table> |