Skip to content

Commit

Permalink
Update Querycollector with SQLite Explain support (barryvdh#1315)
Browse files Browse the repository at this point in the history
This adds support for SQLite EXPLAIN statement. There is no support for EXPLAIN QUERY PLAN yet, as this would require more changes to the package config.
  • Loading branch information
mikewink authored Oct 31, 2022
1 parent 9bb3381 commit 615ce47
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/DataCollector/QueryCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,41 @@ public function collect()
'type' => 'explain',
];
}
} elseif ($query['driver'] === 'sqlite') {
$vmi = '<table style="margin:-5px -11px !important;width: 100% !important">';
$vmi .= "<thead><tr>
<td>Address</td>
<td>Opcode</td>
<td>P1</td>
<td>P2</td>
<td>P3</td>
<td>P4</td>
<td>P5</td>
<td>Comment</td>
</tr></thead>";

foreach ($query['explain'] as $explain) {
$vmi .= "<tr>
<td>{$explain->addr}</td>
<td>{$explain->opcode}</td>
<td>{$explain->p1}</td>
<td>{$explain->p2}</td>
<td>{$explain->p3}</td>
<td>{$explain->p4}</td>
<td>{$explain->p5}</td>
<td>{$explain->comment}</td>
</tr>";
}

$vmi .= '</table>';

$statements[] = [
'sql' => " - EXPLAIN:",
'type' => 'explain',
'params' => [
'Virtual Machine Instructions' => $vmi,
]
];
} else {
foreach ($query['explain'] as $explain) {
$statements[] = [
Expand Down

0 comments on commit 615ce47

Please sign in to comment.