class Relation (View source)

Set of functions used with the relation and PDF feature

Properties

DatabaseInterface $dbi
Template $template

Methods

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

No description

mixed|bool
queryAsControlUser(string $sql, bool $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, bool $skip_line = true)

prints out one diagnostic message for a feature

string
getDiagMessageForParameter(string $parameter, bool $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
canAccessStorageTable(string $tableDbName)

Check if the table is accessible

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

bool
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|bool $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|false
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.

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

Search a table column in foreign data.

array
getDefaultPmaTableNames(array $tableNameReplacements)

Returns default PMA table names and their create queries.

bool
createPmaDatabase(string $configurationStorageDbName)

Create a database to be used as configuration storage

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

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

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

Get Html for PMA tables fixing anchor.

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

Gets the relations info and status, depending on the condition

bool
arePmadbTablesDefined()

Verifies if all the pmadb tables are defined

array
getTables(string $foreignDb, string $tblStorageEngine)

Get tables for foreign key constraint

string

Details

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

No description

Parameters

DatabaseInterface|null $dbi

Database interface

Template|null $template

Template instance

mixed|bool queryAsControlUser(string $sql, bool $show_error = true, int $options = 0)

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

Parameters

string $sql

the query to execute

bool $show_error

whether to display SQL error messages or not

int $options

query options

Return Value

mixed|bool

the result set, or false if no result set

array getRelationsParam()

Returns current relation parameters

Return Value

array

string getRelationsParamDiagnostic(array $cfgRelation)

prints out diagnostic info for pma relation feature

Parameters

array $cfgRelation

Relation configuration

Return Value

string

string getDiagMessageForFeature(string $feature_name, string $relation_parameter, array $messages, bool $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

bool $skip_line

whether to skip a line after the message

Return Value

string

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

prints out one diagnostic message for a configuration parameter

Parameters

string $parameter

config parameter name to display

bool $relationParameterSet

whether this parameter is set

array $messages

utility messages

string $docAnchor

anchor in documentation

Return Value

string

protected 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

bool canAccessStorageTable(string $tableDbName)

Check if the table is accessible

Parameters

string $tableDbName

The table or table.db

Return Value

bool

bool tryUpgradeTransformations()

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

Return Value

bool

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

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

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

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

array getDbComments()

Gets the comment for a db

Return Value

array

comments

bool 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

bool

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

array|bool getHistory(string $username)

Gets a SQL history entry

Parameters

string $username

the username

Return Value

array|bool

list of history items

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

protected 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

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

array getForeignData(array|bool $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|bool $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

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

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

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

int|false 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|false

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

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

foreigners 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.

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

Search a table column in foreign data.

Parameters

array $foreigners

Table Foreign data

string $column

Column name

Return Value

array|false

array getDefaultPmaTableNames(array $tableNameReplacements)

Returns default PMA table names and their create queries.

Parameters

array $tableNameReplacements

Return Value

array

table name, create query

bool createPmaDatabase(string $configurationStorageDbName)

Create a database to be used as configuration storage

Parameters

string $configurationStorageDbName

Return Value

bool

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

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

Parameters

string $db

database

bool $create

whether to create tables if they don't exist.

Return Value

void

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

Get Html for PMA tables fixing anchor.

Parameters

bool $allTables

whether to create all tables

bool $createDb

whether to create the pmadb also

Return Value

string

Html

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

Gets the relations info and status, depending on the condition

Parameters

bool $condition

whether to look for foreigners or not

string $db

database name

string $table

table name

Return Value

array

($res_rel, $have_rel)

bool arePmadbTablesDefined()

Verifies if all the pmadb tables are defined

Return Value

bool

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

string getConfigurationStorageDbName()

No description

Return Value

string