/QueryExplain.php

Description
Classes
Class Description
QueryExplain
Includes
require ("QueryTableParser.php") (line 45)

class QueryExplain rough utility class to get query explain plan and extract table names from abitrary sql so we can run show create table on them.

This class needs a user defined method to find the database connection info from the query and a bit of other data stored with the query_review_history table

The class is used as follows:

$result = $mysqli->query("SELECT sample, hostname_max, database_max FROM query_review_history WHERE checksum=1"); $row = $result->fetch_assoc();

$explainer = new QueryExplain($callback, $row); print $explainer->explain();

where $callback might look like: $callback = function(array $sample) { return array( 'host' => $sample['hostname_max'], 'db' => $sample['database_max'], 'user' => 'username', 'password' => 'password', ); }

The callback funtion will always take one array argument, and it needs to return and array with the following keys defined: host,db,user,password; and optionally: port

Because the object takes data associated with one query to return the db connection info, that means a QueryExplain object will always only be valid for one query, and will maintain its own connection

Sharing connection objects would be advantageous if you want to explain many queries which could be from the same database; but that's not needed for it's current use case.

Documentation generated on Mon, 12 Mar 2012 11:59:41 -0700 by phpDocumentor 1.4.4