class Relation

Set of functions used with the relation and PDF feature

Properties

DatabaseInterface $dbi
Template $template

Methods

__construct(DatabaseInterface|null $dbi, Template|null $template = null)

Relation constructor.

resource|boolean
queryAsControlUser(string $sql, boolean $show_error = true, int $options = 0)

Executes a query as controluser if possible, otherwise as normal user

array
getRelationsParam()

Returns current relation parameters

string
getRelationsParamDiagnostic(array $cfgRelation)

prints out diagnostic info for pma relation feature

string
getDiagMessageForFeature(string $feature_name, string $relation_parameter, array $messages, boolean $skip_line = true)

prints out one diagnostic message for a feature

string
getDiagMessageForParameter(string $parameter, boolean $relationParameterSet, array $messages, string $docAnchor)

prints out one diagnostic message for a configuration parameter

array
checkRelationsParam()

Defines the relation parameters for the current user just a copy of the functions used for relations ;-) but added some stuff to check what will work

bool
tryUpgradeTransformations()

Check whether column_info table input transformation upgrade is required and try to upgrade silently

array
getForeigners(string $db, string $table, string $column = '', string $source = 'both')

Gets all Relations to foreign tables for a given table or optionally a given column in a table

string|false
getDisplayField(string $db, string $table)

Gets the display field of a table

array
getComments(string $db, string $table = '')

Gets the comments for all columns of a table or the db itself

string
getDbComment(string $db)

Gets the comment for a db

array
getDbComments()

Gets the comment for a db

boolean
setDbComment(string $db, string $comment = '')

Set a database comment to a certain value.

void
setHistory(string $db, string $table, string $username, string $sqlquery)

Set a SQL history entry

array|bool
getHistory(string $username)

Gets a SQL history entry

void
purgeHistory(string $username)

purges SQL history

array
buildForeignDropdown(array $foreign, string $data, string $mode)

Prepares the dropdown for one mode

string
foreignDropdown(array $disp_row, string $foreign_field, string $foreign_display, string $data, int $max = null)

Outputs dropdown with values of foreign fields

array
getForeignData(array|boolean $foreigners, string $field, bool $override_total, string $foreign_filter, string $foreign_limit, bool $get_total = false)

Gets foreign keys in preparation for a drop-down selector

void
renameField(string $db, string $table, string $field, string $new_name)

Rename a field in relation tables

void
renameSingleTable(string $table, string $source_db, string $target_db, string $source_table, string $target_table, string $db_field, string $table_field)

Performs SQL query used for renaming table.

void
renameTable(string $source_db, string $target_db, string $source_table, string $target_table)

Rename a table in relation tables

int
createPage(string|null $newpage, array $cfgRelation, string $db)

Create a PDF page

array
getChildReferences(string $db, string $table, string $column = '')

Get child table references for a table column.

array
checkChildForeignReferences(string $db, string $table, string $column, array|null $foreigners_full = null, array|null $child_references_full = null)

Check child table references and foreign key for a table column.

bool|array
searchColumnInForeigners(array $foreigners, string $column)

Search a table column in foreign data.

array
getDefaultPmaTableNames()

Returns default PMA table names and their create queries.

bool
createPmaDatabase()

Create a table named phpmyadmin to be used as configuration storage

void
fixPmaTables(string $db, boolean $create = true)

Creates PMA tables in the given db, updates if already exists.

string
getHtmlFixPmaTables(boolean $allTables, boolean $createDb = false)

Get Html for PMA tables fixing anchor.

array
getRelationsAndStatus(boolean $condition, string $db, string $table)

Gets the relations info and status, depending on the condition

boolean
arePmadbTablesDefined()

Verifies if all the pmadb tables are defined

array
getTables(string $foreignDb, string $tblStorageEngine)

Get tables for foreign key constraint

Details

at line 39
__construct(DatabaseInterface|null $dbi, Template|null $template = null)

Relation constructor.

Parameters

DatabaseInterface|null $dbi Database interface
Template|null $template Template instance

at line 57
resource|boolean queryAsControlUser(string $sql, boolean $show_error = true, int $options = 0)

Executes a query as controluser if possible, otherwise as normal user

Parameters

string $sql the query to execute
boolean $show_error whether to display SQL error messages or not
int $options query options

Return Value

resource|boolean the result set, or false if no result set

at line 93
array getRelationsParam()

Returns current relation parameters

Return Value

array

at line 116
string getRelationsParamDiagnostic(array $cfgRelation)

prints out diagnostic info for pma relation feature

Parameters

array $cfgRelation Relation configuration

Return Value

string

at line 425
string getDiagMessageForFeature(string $feature_name, string $relation_parameter, array $messages, boolean $skip_line = true)

prints out one diagnostic message for a feature

Parameters

string $feature_name feature name in a message string
string $relation_parameter the $GLOBALS['cfgRelation'] parameter to check
array $messages utility messages
boolean $skip_line whether to skip a line after the message

Return Value

string

at line 456
string getDiagMessageForParameter(string $parameter, boolean $relationParameterSet, array $messages, string $docAnchor)

prints out one diagnostic message for a configuration parameter

Parameters

string $parameter config parameter name to display
boolean $relationParameterSet whether this parameter is set
array $messages utility messages
string $docAnchor anchor in documentation

Return Value

string

at line 485
array checkRelationsParam()

Defines the relation parameters for the current user just a copy of the functions used for relations ;-) but added some stuff to check what will work

Return Value

array the relation parameters for the current user

at line 719
bool tryUpgradeTransformations()

Check whether column_info table input transformation upgrade is required and try to upgrade silently

Return Value

bool false if upgrade failed

at line 794
array getForeigners(string $db, string $table, string $column = '', string $source = 'both')

Gets all Relations to foreign tables for a given table or optionally a given column in a table

Parameters

string $db the name of the db to check for
string $table the name of the table to check for
string $column the name of the column to check for
string $source the source for foreign key information

Return Value

array db,table,column

at line 875
string|false getDisplayField(string $db, string $table)

Gets the display field of a table

Parameters

string $db the name of the db to check for
string $table the name of the table to check for

Return Value

string|false field name or false

at line 937
array getComments(string $db, string $table = '')

Gets the comments for all columns of a table or the db itself

Parameters

string $db the name of the db to check for
string $table the name of the table to check for

Return Value

array [column_name] = comment

at line 967
string getDbComment(string $db)

Gets the comment for a db

Parameters

string $db the name of the db to check for

Return Value

string comment

at line 1005
array getDbComments()

Gets the comment for a db

Return Value

array comments

at line 1045
boolean setDbComment(string $db, string $comment = '')

Set a database comment to a certain value.

Parameters

string $db the name of the db
string $comment the value of the column

Return Value

boolean true, if comment-query was made.

at line 1090
void setHistory(string $db, string $table, string $username, string $sqlquery)

Set a SQL history entry

Parameters

string $db the name of the db
string $table the name of the table
string $username the username
string $sqlquery the sql query

Return Value

void

at line 1150
array|bool getHistory(string $username)

Gets a SQL history entry

Parameters

string $username the username

Return Value

array|bool list of history items

at line 1199
void purgeHistory(string $username)

purges SQL history

deletes entries that exceeds $cfg['QueryHistoryMax'], oldest first, for the given user

Parameters

string $username the username

Return Value

void

at line 1246
array buildForeignDropdown(array $foreign, string $data, string $mode)

Prepares the dropdown for one mode

Parameters

array $foreign the keys and values for foreigns
string $data the current data of the dropdown
string $mode the needed mode

Return Value

array the

at line 1348
string foreignDropdown(array $disp_row, string $foreign_field, string $foreign_display, string $data, int $max = null)

Outputs dropdown with values of foreign fields

Parameters

array $disp_row array of the displayed row
string $foreign_field the foreign field
string $foreign_display the foreign field to display
string $data the current data of the dropdown (field in row)
int $max maximum number of items in the dropdown

Return Value

string the

at line 1436
array getForeignData(array|boolean $foreigners, string $field, bool $override_total, string $foreign_filter, string $foreign_limit, bool $get_total = false)

Gets foreign keys in preparation for a drop-down selector

Parameters

array|boolean $foreigners array of the foreign keys
string $field the foreign field name
bool $override_total whether to override the total
string $foreign_filter a possible filter
string $foreign_limit a possible LIMIT clause
bool $get_total optional, whether to get total num of rows in $foreignData['the_total;] (has an effect of performance)

Return Value

array data about the foreign keys

at line 1568
void renameField(string $db, string $table, string $field, string $new_name)

Rename a field in relation tables

usually called after a column in a table was renamed

Parameters

string $db database name
string $table table name
string $field old field name
string $new_name new field name

Return Value

void

at line 1633
void renameSingleTable(string $table, string $source_db, string $target_db, string $source_table, string $target_table, string $db_field, string $table_field)

Performs SQL query used for renaming table.

Parameters

string $table Relation table to use
string $source_db Source database name
string $target_db Target database name
string $source_table Source table name
string $target_table Target table name
string $db_field Name of database field
string $table_field Name of table field

Return Value

void

at line 1671
void renameTable(string $source_db, string $target_db, string $source_table, string $target_table)

Rename a table in relation tables

usually called after table has been moved

Parameters

string $source_db Source database name
string $target_db Target database name
string $source_table Source table name
string $target_table Target table name

Return Value

void

at line 1800
int createPage(string|null $newpage, array $cfgRelation, string $db)

Create a PDF page

Parameters

string|null $newpage name of the new PDF page
array $cfgRelation Relation configuration
string $db database name

Return Value

int

at line 1827
array getChildReferences(string $db, string $table, string $column = '')

Get child table references for a table column.

This works only if 'DisableIS' is false. An empty array is returned otherwise.

Parameters

string $db name of master table db.
string $table name of master table.
string $column name of master table column.

Return Value

array

at line 1865
array checkChildForeignReferences(string $db, string $table, string $column, array|null $foreigners_full = null, array|null $child_references_full = null)

Check child table references and foreign key for a table column.

Parameters

string $db name of master table db.
string $table name of master table.
string $column name of master table column.
array|null $foreigners_full foreiners array for the whole table.
array|null $child_references_full child references for the whole table.

Return Value

array telling about references if foreign key.

at line 1929
bool|array searchColumnInForeigners(array $foreigners, string $column)

Search a table column in foreign data.

Parameters

array $foreigners Table Foreign data
string $column Column name

Return Value

bool|array

at line 1965
array getDefaultPmaTableNames()

Returns default PMA table names and their create queries.

Return Value

array table name, create query

at line 1993
bool createPmaDatabase()

Create a table named phpmyadmin to be used as configuration storage

Return Value

bool

at line 2019
void fixPmaTables(string $db, boolean $create = true)

Creates PMA tables in the given db, updates if already exists.

Parameters

string $db database
boolean $create whether to create tables if they don't exist.

Return Value

void

at line 2104
string getHtmlFixPmaTables(boolean $allTables, boolean $createDb = false)

Get Html for PMA tables fixing anchor.

Parameters

boolean $allTables whether to create all tables
boolean $createDb whether to create the pmadb also

Return Value

string Html

at line 2156
array getRelationsAndStatus(boolean $condition, string $db, string $table)

Gets the relations info and status, depending on the condition

Parameters

boolean $condition whether to look for foreigners or not
string $db database name
string $table table name

Return Value

array ($res_rel, $have_rel)

at line 2183
boolean arePmadbTablesDefined()

Verifies if all the pmadb tables are defined

Return Value

boolean

at line 2214
array getTables(string $foreignDb, string $tblStorageEngine)

Get tables for foreign key constraint

Parameters

string $foreignDb Database name
string $tblStorageEngine Table storage engine

Return Value

array Table names