dzegarra/tracy-mysqli

This lib extends mysqli to allow you to see all your executed queries. It also includes a Bar Panel for Tracy

Installs: 7 396

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 1

Forks: 17

Open Issues: 1

Type:package

1.1.1 2017-02-24 11:34 UTC

This package is not auto-updated.

Last update: 2024-04-17 18:11:40 UTC


README

This lib allow you to see all your executed SQL queries when you are using the MySQLi php driver. It also includes a Bar Panel for Tracy, see the result below.

Result

MySQLi logger with Tracy

Installation

Install it via composer:

composer require dzegarra/tracy-mysqli

How to use

// Create an instance for Tracy Bar Panel
$panel = new \Dzegarra\TracyMysqli\BarPanel();

// Add the panel to Tracy
\Tracy\Debugger::getBar()->addPanel($panel);

// Make a connection to the DB using the \Dzegarra\TracyMysqli\Mysqli class instead of mysqli
$conn = new \Dzegarra\TracyMysqli\Mysqli("hostname", "username", "password", "database");

// Execute your queries

How it works

First you need to add the panel to the Tracy bar. The panel won't be render until the shutdown process kick in (either way the script ends or you call die or exit).

Just before the panel start to render the list of all the SQL querys will be fetched from the Mysqli class.

All the queries are store in a static variable in the Mysqli so, no matters how many instances of the Mysqli class you create, all the queries of all the instances will be store.

Inspiration and credits

This repo is based in filisko/pdo-plus.