Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix explaining queries #802

Merged
merged 1 commit into from Apr 20, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 16 additions & 2 deletions Controller/ProfilerController.php
Expand Up @@ -8,6 +8,7 @@
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Profiler\Profiler;
use Symfony\Component\VarDumper\Cloner\Data;

/**
* ProfilerController.
Expand Down Expand Up @@ -77,14 +78,27 @@ private function explainSQLServerPlatform(Connection $connection, $query)
} else {
$sql = 'SET SHOWPLAN_TEXT ON; GO; SET NOEXEC ON; ' . $query['sql'] . '; SET NOEXEC OFF; GO; SET SHOWPLAN_TEXT OFF;';
}
$stmt = $connection->executeQuery($sql, $query['params'], $query['types']);

$params = $query['params'];

if ($params instanceof Data) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you create a function with an explicit name and call it in both place ?

$params = $params->getValue(true);
}

$stmt = $connection->executeQuery($sql, $params, $query['types']);
$stmt->nextRowset();
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
}

private function explainOtherPlatform(Connection $connection, $query)
{
return $connection->executeQuery('EXPLAIN ' . $query['sql'], $query['params'], $query['types'])
$params = $query['params'];

if ($params instanceof Data) {
$params = $params->getValue(true);
}

return $connection->executeQuery('EXPLAIN ' . $query['sql'], $params, $query['types'])
->fetchAll(\PDO::FETCH_ASSOC);
}
}