Properties

$mysqli

$mysqli : \mysqli

Type

\mysqli

$conf

$conf : 

Type

$query

$query : 

Type

$get_connection_func

$get_connection_func : 

Type

$CONNECT_TIMEOUT

$CONNECT_TIMEOUT : 

Type

Methods

__construct()

__construct(callback  $get_connection_func, array  $sample) 

Constructor. See class documentation for explanation of the parameters

Parameters

callback $get_connection_func

The callback function

array $sample

array of information about the query

Throws

\RuntimeException

if a database connection cannot be made

\InvalidArgumentException

if $get_connection_func is not a function

get_tables_from_query()

get_tables_from_query(\QueryTableParser  $parser) : array

Try to parse the real table names out of a sql query

Parameters

\QueryTableParser $parser

instance of QueryTableParser()

Returns

array —

the list of tables in the query

get_create()

get_create() : string

Extract the table names from a query, and return the result of SHOW CREATE TABLE tablename;

Returns

string —

the create table statements, or an error message

get_table_status()

get_table_status() : null

Extract the table names and the return the result of SHOW TABLE STATUS LIKE 'tablename' for each table;

Returns

null

explain()

explain() : null|string

If the given query is a SELECT statement, return the explain plan

Returns

null|string —

The explain plan, or an error message

result_as_table()

result_as_table(\{MySQLi_Result}  $result) : \{string}

given a mysqli result handle, format a string to look like the mysql cli type tables

Parameters

\{MySQLi_Result} $result

The result set handle

Returns

\{string} —

The formatted result set string

connect()

connect() : boolean

Attempt to connect to the connection info returned from the callback function used to construct the object.

Throws

\RuntimeException

throws errors on connect to the database

Returns

boolean —

true if successful

explain_query()

explain_query() : \MySQLi_Result

Execute EXPLAIN $query and return the result

Returns

\MySQLi_Result —

the result handle

make_row()

make_row(array  $sizes, array  $values, array  $order) 

utility method for result_as_table

Parameters

array $sizes
array $values
array $order

make_rule()

make_rule(array  $sizes, array  $order) 

utility method for result_as_table

Parameters

array $sizes
array $order