class Sql (View source)

Set of functions for the SQL executor

Methods

__construct()

No description

mixed
parseAndAnalyze(string $sql_query, string $db = null)

Parses and analyzes the given SQL query.

string
getHtmlForRelationalColumnDropdown(string $db, string $table, string $column, string $curr_value)

Get the HTML for relational column dropdown During grid edit, if we have a relational field, returns the html for the dropdown

string
getHtmlForSetColumn(string $db, string $table, string $column, string $curr_value)

Get the HTML for the set column dropdown During grid edit, if we have a set field, returns the html for the dropdown

array
getValuesForColumn(string $db, string $table, string $column)

Get all the values for a enum column or set column in a table

string
getHtmlForBookmark(array $displayParts, array $cfgBookmark, string $sql_query, string $db, string $table, string|null $complete_query, string $bkm_user)

Function to get html for bookmark support if bookmarks are enabled. Else will return null

static bool
isJustBrowsing(array $analyzed_sql_results, bool|null $find_real_end)

Function to check whether this query is for just browsing

bool
hasNoRightsToDropDatabase(array $analyzed_sql_results, bool $allowUserDropDatabase, bool $is_superuser)

Function to check whether the user has rights to drop the database

bool|Message
setColumnProperty(Table $pmatable, string $request_index)

Function to set a column property

mixed
findRealEndOfRows(string $db, string $table)

Function to find the real end of rows

string
getDefaultSqlQueryForBrowse(string $db, string $table)

Function to get the default sql query for browsing page

void
storeTheQueryAsBookmark(string $db, string $bkm_user, string $sql_query_for_bookmark, string $bkm_label, bool $bkm_replace)

Function to store the query as a bookmark

string
executeQueryAndSendQueryResponse(array|null $analyzed_sql_results, bool $is_gotofile, string $db, string|null $table, bool|null $find_real_end, string|null $sql_query_for_bookmark, array|null $extra_data, string|null $message_to_show, Message|string|null $message, array|null $sql_data, string $goto, string $pmaThemeImage, string|null $disp_query, Message|string|null $disp_message, string|null $query_type, string $sql_query, array|null $selectedTables, string|null $complete_query)

Function to execute the query and send the response

string
executeQueryAndGetQueryResponse(array $analyzed_sql_results, bool $is_gotofile, string|null $db, string|null $table, bool|null $find_real_end, string|null $sql_query_for_bookmark, array|null $extra_data, string|null $message_to_show, Message|string|null $message, array|null $sql_data, string $goto, string $pmaThemeImage, string|null $disp_query, Message|string|null $disp_message, string|null $query_type, string $sql_query, array|null $selectedTables, string|null $complete_query)

Function to execute the query and send the response

int
calculatePosForLastPage(string $db, string $table, int|null $pos)

Function to calculate new pos if pos is higher than number of rows of displayed table

Details

__construct()

mixed parseAndAnalyze(string $sql_query, string $db = null)

Parses and analyzes the given SQL query.

Parameters

string $sql_query SQL query
string $db DB name

Return Value

mixed

string getHtmlForRelationalColumnDropdown(string $db, string $table, string $column, string $curr_value)

Get the HTML for relational column dropdown During grid edit, if we have a relational field, returns the html for the dropdown

Parameters

string $db current database
string $table current table
string $column current column
string $curr_value current selected value

Return Value

string html for the dropdown

string getHtmlForSetColumn(string $db, string $table, string $column, string $curr_value)

Get the HTML for the set column dropdown During grid edit, if we have a set field, returns the html for the dropdown

Parameters

string $db current database
string $table current table
string $column current column
string $curr_value currently selected value

Return Value

string html for the set column

array getValuesForColumn(string $db, string $table, string $column)

Get all the values for a enum column or set column in a table

Parameters

string $db current database
string $table current table
string $column current column

Return Value

array array containing the value list for the column

string getHtmlForBookmark(array $displayParts, array $cfgBookmark, string $sql_query, string $db, string $table, string|null $complete_query, string $bkm_user)

Function to get html for bookmark support if bookmarks are enabled. Else will return null

Parameters

array $displayParts the parts to display
array $cfgBookmark configuration setting for bookmarking
string $sql_query sql query
string $db current database
string $table current table
string|null $complete_query complete query
string $bkm_user bookmarking user

Return Value

string

static bool isJustBrowsing(array $analyzed_sql_results, bool|null $find_real_end)

Function to check whether this query is for just browsing

Parameters

array $analyzed_sql_results the analyzed query and other variables set after analyzing the query
bool|null $find_real_end whether the real end should be found

Return Value

bool

bool hasNoRightsToDropDatabase(array $analyzed_sql_results, bool $allowUserDropDatabase, bool $is_superuser)

Function to check whether the user has rights to drop the database

Parameters

array $analyzed_sql_results the analyzed query and other variables set after analyzing the query
bool $allowUserDropDatabase whether the user is allowed to drop db
bool $is_superuser whether this user is a superuser

Return Value

bool

bool|Message setColumnProperty(Table $pmatable, string $request_index)

Function to set a column property

Parameters

Table $pmatable Table instance
string $request_index col_order|col_visib

Return Value

bool|Message

mixed findRealEndOfRows(string $db, string $table)

Function to find the real end of rows

Parameters

string $db the current database
string $table the current table

Return Value

mixed the number of rows if "retain" param is true, otherwise true

string getDefaultSqlQueryForBrowse(string $db, string $table)

Function to get the default sql query for browsing page

Parameters

string $db the current database
string $table the current table

Return Value

string the default $sql_query for browse page

void storeTheQueryAsBookmark(string $db, string $bkm_user, string $sql_query_for_bookmark, string $bkm_label, bool $bkm_replace)

Function to store the query as a bookmark

Parameters

string $db the current database
string $bkm_user the bookmarking user
string $sql_query_for_bookmark the query to be stored in bookmark
string $bkm_label bookmark label
bool $bkm_replace whether to replace existing bookmarks

Return Value

void

string executeQueryAndSendQueryResponse(array|null $analyzed_sql_results, bool $is_gotofile, string $db, string|null $table, bool|null $find_real_end, string|null $sql_query_for_bookmark, array|null $extra_data, string|null $message_to_show, Message|string|null $message, array|null $sql_data, string $goto, string $pmaThemeImage, string|null $disp_query, Message|string|null $disp_message, string|null $query_type, string $sql_query, array|null $selectedTables, string|null $complete_query)

Function to execute the query and send the response

Parameters

array|null $analyzed_sql_results analysed sql results
bool $is_gotofile whether goto file or not
string $db current database
string|null $table current table
bool|null $find_real_end whether to find real end or not
string|null $sql_query_for_bookmark the sql query to be stored as bookmark
array|null $extra_data extra data
string|null $message_to_show message to show
Message|string|null $message message
array|null $sql_data sql data
string $goto goto page url
string $pmaThemeImage uri of the PMA theme image
string|null $disp_query display query
Message|string|null $disp_message display message
string|null $query_type query type
string $sql_query sql query
array|null $selectedTables array of table names selected from the database structure page, for an action like check table, optimize table, analyze table or repair table
string|null $complete_query complete query

Return Value

string

string executeQueryAndGetQueryResponse(array $analyzed_sql_results, bool $is_gotofile, string|null $db, string|null $table, bool|null $find_real_end, string|null $sql_query_for_bookmark, array|null $extra_data, string|null $message_to_show, Message|string|null $message, array|null $sql_data, string $goto, string $pmaThemeImage, string|null $disp_query, Message|string|null $disp_message, string|null $query_type, string $sql_query, array|null $selectedTables, string|null $complete_query)

Function to execute the query and send the response

Parameters

array $analyzed_sql_results analysed sql results
bool $is_gotofile whether goto file or not
string|null $db current database
string|null $table current table
bool|null $find_real_end whether to find real end or not
string|null $sql_query_for_bookmark the sql query to be stored as bookmark
array|null $extra_data extra data
string|null $message_to_show message to show
Message|string|null $message message
array|null $sql_data sql data
string $goto goto page url
string $pmaThemeImage uri of the PMA theme image
string|null $disp_query display query
Message|string|null $disp_message display message
string|null $query_type query type
string $sql_query sql query
array|null $selectedTables array of table names selected from the database structure page, for an action like check table, optimize table, analyze table or repair table
string|null $complete_query complete query

Return Value

string html

int calculatePosForLastPage(string $db, string $table, int|null $pos)

Function to calculate new pos if pos is higher than number of rows of displayed table

Parameters

string $db Database name
string $table Table name
int|null $pos Initial position

Return Value

int Number of pos to display last page