Skip to content

Commit fbb8a34

Browse files
authored
Merge pull request doctrine#802 from stof/fix_explain
Fix explaining queries
2 parents 703fad3 + 6de4d03 commit fbb8a34

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

Controller/ProfilerController.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symfony\Component\DependencyInjection\ContainerInterface;
99
use Symfony\Component\HttpFoundation\Response;
1010
use Symfony\Component\HttpKernel\Profiler\Profiler;
11+
use Symfony\Component\VarDumper\Cloner\Data;
1112

1213
/**
1314
* ProfilerController.
@@ -77,14 +78,27 @@ private function explainSQLServerPlatform(Connection $connection, $query)
7778
} else {
7879
$sql = 'SET SHOWPLAN_TEXT ON; GO; SET NOEXEC ON; ' . $query['sql'] . '; SET NOEXEC OFF; GO; SET SHOWPLAN_TEXT OFF;';
7980
}
80-
$stmt = $connection->executeQuery($sql, $query['params'], $query['types']);
81+
82+
$params = $query['params'];
83+
84+
if ($params instanceof Data) {
85+
$params = $params->getValue(true);
86+
}
87+
88+
$stmt = $connection->executeQuery($sql, $params, $query['types']);
8189
$stmt->nextRowset();
8290
return $stmt->fetchAll(\PDO::FETCH_ASSOC);
8391
}
8492

8593
private function explainOtherPlatform(Connection $connection, $query)
8694
{
87-
return $connection->executeQuery('EXPLAIN ' . $query['sql'], $query['params'], $query['types'])
95+
$params = $query['params'];
96+
97+
if ($params instanceof Data) {
98+
$params = $params->getValue(true);
99+
}
100+
101+
return $connection->executeQuery('EXPLAIN ' . $query['sql'], $params, $query['types'])
88102
->fetchAll(\PDO::FETCH_ASSOC);
89103
}
90104
}

0 commit comments

Comments
 (0)