2017 © Pedro Peláez
 

library mysqlnduhtool

Mysql analyze tool. Find, log, mock and change your php database queries without touching your code.

image

mysqlnduhtool/mysqlnduhtool

Mysql analyze tool. Find, log, mock and change your php database queries without touching your code.

  • Friday, December 9, 2011
  • by gimler
  • Repository
  • 1 Watchers
  • 9 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

MySQLndUhTool, locate change control your mysql commands

MySQLndUhTool is proxy that add events to the mysql commands. So you can not only log queries you get the line, file and server on which the spocky query was executed., (*1)

Requirements

MySQLndUhTool requires mysqlnd and the pecl extension mysqlnd_uh [2]., (*2)

Installation

Installing MySQLndUhTool is as easy as it can get. Download the mysqlnduhtool.phar file and you're done!, (*3)

Usage

Require the MySQLndUhTool phar file to use MySQLndUhTool in a script:, (*4)

require_once '/path/to/MySQLndUhTool.phar';

Create a Symfony EventDispatcher instance:, (*5)

use Symfony\Component\EvenDispatcher\EvenDispatcher;

$eventDispatcher = new EvenDispatcher();

Create a MySQLndUhTool Proxy instance with the dispatcher (which extends MySQLndUhConnection):, (*6)

use MySQLndUhTool\Proxy;

$proxy = new Proxy($eventDispatcher);

Get build in informations

How many query were executed:, (*7)

$proxy->countExecutedQueries();

// unique queries
$proxy->countUniqueQueries());

Which queries were executed:, (*8)

// get array with sql => backtrace
$proxy->getSqlQueries();

Check for sepcific query:, (*9)

$proxy->hasQuery($sql);

Add listener to the events

  1. create a callback (closure, static function ...), (*10)

    $callback = function(MySQLndUhTool\Event\Query $event) {
        $backtrace = debug_backtrace();
        $file      = $backtrace[5]['file'];
        $line      = $backtrace[5]['line'];
        error_log(sprintf('%s line %u bullshit %s', $file, $line, $event->getQuery()));
    };
  2. add the callback for specific event to the dispatcher, (*11)

    $eventDispatcher->addListener(MySQLndUhTool\QueryEvents::FAIL, $callback[, $priority]);

Automatically integration in every php process

There are two usefull php ini option with that you can prepend the bootstrap of MySQLndUhTool auto_prepend_file and append option auto_append_file for log/output build in informations or do other stuff., (*12)

Technical Information

MySQLndUhTool is a proxy around the MySQLndUhConnection class it use the following fine PHP libraries:, (*13)

  • Symfony Components: ClassLoader, EventDispatcher

And the following pecl extension:, (*14)

  • mysqlnd_uh

License

MySQLndUhTool is licensed under the MIT license., (*15)

The Versions

09/12 2011

dev-master

9999999-dev http://github.com/gimler/MySQLndUhTool

Mysql analyze tool. Find, log, mock and change your php database queries without touching your code.

  Sources   Download

MIT

The Requires

 

database debug mysql db mysqlnd