public function getAttributes()
{
$queries = [];
foreach ($this->queries as $query) {
$sql = $query['sql'];
$bindings = $query['bindings'];
$pdo = $query['pdo'];
$driver = $query['driver'];
$version = 0;
$fullSql = self::prepareBindings($sql, $bindings);
$formattedSql = self::formatSql($fullSql);
$explains = [];
$hints = [];
if ($pdo instanceof PDO) {
try {
$driver = $pdo->getAttribute(PDO::ATTR_DRIVER_NAME);
} catch (Exception $e) {
$driver = null;
}
if ($driver === 'mysql') {
$explains = static::explain($pdo, $sql, $bindings);
try {
$version = $pdo->getAttribute(PDO::ATTR_SERVER_VERSION);
} catch (Exception $e) {
}
$hints = static::performQueryAnalysis($fullSql, $version, $driver);
}
}
$queries[] = array_merge($query, compact('fullSql', 'formattedSql', 'explains', 'hints', 'driver', 'version'));
}
return ['counter' => $this->counter, 'totalTime' => $this->totalTime, 'queries' => $queries];
}