Properties

$conf

$conf : 

Type

$datasource_name

$datasource_name : 

Type

$mysqli

$mysqli : 

Type

$fact_table

$fact_table : 

Type

$dimension_table

$dimension_table : 

Type

Methods

__construct()

__construct(array  $conf) 

Constructor. Initialize the model object

Parameters

array $conf

The global config information

get_default_report_action()

get_default_report_action() : string

return the default report action name; usually either report or graph_search

Returns

string —

the action name

get_report_defaults()

get_report_defaults(string  $type = 'report_defaults') : array

get the default search values for the specified report type

Parameters

string $type

The name of the report type

Returns

array —

The default values for the search form

get_source_type()

get_source_type() 

get_review_types()

get_review_types() : array

return the list of review types. This is a configurable list of short text statuses that can describe the query.

Returns

array —

the list of review status types

get_data_source_names()

get_data_source_names() : array

Get the list of names for the configured data sources

Returns

array —

List of strings that describe the data sources

get_data_source()

get_data_source(string  $name) : mixed

Given a data source name, get the properties for it.

Parameters

string $name

The datasource name

Returns

mixed —

array of properties, or null if the datasource doesn't exist

set_data_source()

set_data_source(string  $name) 

sets the currently active datasource.

Parameters

string $name

The name of the datasource

get_table_aliases()

get_table_aliases() 

set_tables()

set_tables(string  $fact, string  $dimension) 

set the current fact and dimension table. That is the query_review and query_review_history tables. This is used when we select samples or update a query by its checksum.

Parameters

string $fact

The name of the fact table

string $dimension

The name of the dimension table

get_form_fields()

get_form_fields(string  $name) : array

get the field names for the given report

Parameters

string $name

The report name

Returns

array —

the table alias and field names

get_report()

get_report(string  $name) : array

get the full config information for the given report.

Parameters

string $name

The report name

Returns

array —

The configuration information

get_reviewers()

get_reviewers() : array

Return a list of reviewers defined by the config file

Returns

array —

The list of reviewers

checksum_exists()

checksum_exists(string  $checksum) : boolean

Query the database and return true if a given checksum exists

Parameters

string $checksum

The checksum to check

Returns

boolean —

true if it exists, otherwise false

update_query()

update_query(string  $checksum, array  $fields) 

Preform an update query on the given checksum

Parameters

string $checksum

The checksum to update

array $fields

Array of Key => Value pairs to update

get_query_by_checksum()

get_query_by_checksum(string  $checksum) : mixed

given a checksum, return the full database row from the fact table for it.

Parameters

string $checksum

The checksum to retrieve

Returns

mixed —

The row of data, or null

get_query_samples()

get_query_samples(string  $checksum, integer  $limit = 1, integer  $offset) : \MySQLi_Result

Retrieve query samples from the history table, ordered from most recent

Parameters

string $checksum

The checksum to look up

integer $limit

The number of sample to get (default 1)

integer $offset

The starting record number

Returns

\MySQLi_Result —

The result handle

connect_to_datasource()

connect_to_datasource() 

Try to connect to the datasource, throw an exception on failure

Throws

\Exception

init_query_explainer()

init_query_explainer(array  $sample) 

Create a new query explainer object for the given query sample

Parameters

array $sample

The query sample

get_explain_for_sample()

get_explain_for_sample(array  $sample) : mixed

try to get the explain plan for a query

Parameters

array $sample

The query sample row data

Returns

mixed —

Either a string with the explain plan, an error message or null

get_visual_explain()

get_visual_explain(string  $explain_plan) : string

invoke pt-visual-explain and get its output

Parameters

string $explain_plan

The explain plan to feed the script

Returns

string —

The visual explain output

get_query_advisor()

get_query_advisor(string  $query) : string

invoke pt-query-advisor and get its output

Parameters

string $query

The query to feed the script

Returns

string —

The script output

get_create_table()

get_create_table(string  $query) : string

Get the create table definitions for the query

Parameters

string $query

the query to process

Returns

string —

The create table statements

get_table_status()

get_table_status(string  $query) : string

Get the table status info for the given query

Parameters

string $query

The query to process

Returns

string —

The table status info

get_field_name()

get_field_name(  $type) 

Parameters

$type

get_callbacks()

get_callbacks(  $source_type,   $output) 

Parameters

$source_type
$output

exec_external_script()

exec_external_script(string  $script, string  $input) : string

Open a two-way communication with an external script. Used to send data to the program on STDIN and collect output on STDOUT.

Parameters

string $script

The script to invoke

string $input

The input to send to the script on STDIN

Returns

string —

The output from the script