class ExportSql extends ExportPlugin (View source)

Handles the export for the SQL class

Properties

protected ExportPluginProperties $properties

Object containing the specific export plugin type properties.

from  ExportPlugin
Relation $relation from  ExportPlugin
protected Export $export from  ExportPlugin
protected Transformations $transformations from  ExportPlugin

Methods

__construct()

No description

bool
exportHeader()

Outputs export header. It is the first method to be called, so all the required variables are initialized here.

bool
exportFooter()

Outputs export footer

bool
exportDBHeader(string $db, string $dbAlias = '')

Outputs database header

bool
exportDBFooter(string $db)

Outputs database footer

bool
exportDBCreate(string $db, string $exportType, string $dbAlias = '')

Outputs CREATE DATABASE statement

bool
exportData(string $db, string $table, string $crlf, string $errorUrl, string $sqlQuery, array $aliases = [])

Outputs the content of a table in SQL format

bool
exportRoutines(string $db, array $aliases = [])

Exports routines (procedures and functions)

bool
exportEvents(string $db)

Exports events

bool
exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf)

Outputs a raw query

bool
exportStructure(string $db, string $table, string $crlf, string $errorUrl, string $exportMode, string $exportType, bool $relation = false, bool $comments = false, bool $mime = false, bool $dates = false, array $aliases = [])

Outputs table's structure

bool
exportMetadata(string $db, string|array $tables, array $metadataTypes)

Exports metadata from Configuration Storage

string
getTableDefStandIn(string $db, string $view, string $crlf, array $aliases = [])

Returns a stand-in CREATE definition to resolve view dependencies

string
getTriggers(string $db, string $table)

Outputs triggers

void
init()

Plugin specific initializations.

getProperties()

Gets the export specific format plugin properties

setProperties()

Sets the export plugins properties and is implemented by each export plugin.

void
initAlias(array $aliases, string $db, string $table = null)

Initialize aliases

string
getAlias(array $aliases, string $id, string $type = 'dbtblcol', string $db = '', string $tbl = '')

Search for alias of a identifier.

string
getRelationString(array $foreigners, string $fieldName, string $db, array $aliases = [])

Gives the relation string and also substitutes with alias if required in this format: [Foreign Table] ([Foreign Field])

bool
isAvailable()

No description

string
getName()

No description

string
exportRoutineSQL(string $db, array $aliases, string $type, string $name, array $routines, string $delimiter)

Generates SQL for routines export

string
getTableDef(string $db, string $table, string $crlf, string $errorUrl, bool $showDates = false, bool $addSemicolon = true, bool $view = false, bool $updateIndexesIncrements = true, array $aliases = [])

Returns $table's CREATE definition

string
replaceWithAliases(string $sqlQuery, array $aliases, string $db, string $table = '', string $flag = null)

replaces db/table/column names with their aliases

string
generateComment(string $crlf, string|null $sqlStatement, string $comment1, string $comment2, string $tableAlias, string $compat)

Generate comment

Details

final __construct()

No description

bool exportHeader()

Outputs export header. It is the first method to be called, so all the required variables are initialized here.

Return Value

bool

bool exportFooter()

Outputs export footer

Return Value

bool

bool exportDBHeader(string $db, string $dbAlias = '')

Outputs database header

Parameters

string $db

Database name

string $dbAlias

Aliases of db

Return Value

bool

bool exportDBFooter(string $db)

Outputs database footer

Parameters

string $db

Database name

Return Value

bool

bool exportDBCreate(string $db, string $exportType, string $dbAlias = '')

Outputs CREATE DATABASE statement

Parameters

string $db

Database name

string $exportType

'server', 'database', 'table'

string $dbAlias

Aliases of db

Return Value

bool

bool exportData(string $db, string $table, string $crlf, string $errorUrl, string $sqlQuery, array $aliases = [])

Outputs the content of a table in SQL format

Parameters

string $db

database name

string $table

table name

string $crlf

the end of line sequence

string $errorUrl

the url to go back in case of error

string $sqlQuery

SQL query for obtaining data

array $aliases

Aliases of db/table/columns

Return Value

bool

bool exportRoutines(string $db, array $aliases = [])

Exports routines (procedures and functions)

Parameters

string $db Database
array $aliases

Aliases of db/table/columns

Return Value

bool

bool exportEvents(string $db)

Exports events

Parameters

string $db Database

Return Value

bool

bool exportRawQuery(string $errorUrl, string $sqlQuery, string $crlf)

Outputs a raw query

Parameters

string $errorUrl

the url to go back in case of error

string $sqlQuery

the rawquery to output

string $crlf

the seperator for a file

Return Value

bool

bool exportStructure(string $db, string $table, string $crlf, string $errorUrl, string $exportMode, string $exportType, bool $relation = false, bool $comments = false, bool $mime = false, bool $dates = false, array $aliases = [])

Outputs table's structure

Parameters

string $db

database name

string $table

table name

string $crlf

the end of line sequence

string $errorUrl

the url to go back in case of error

string $exportMode

'create_table','triggers','create_view', 'stand_in'

string $exportType

'server', 'database', 'table'

bool $relation

whether to include relation comments

bool $comments

whether to include the pmadb-style column comments as comments in the structure; this is deprecated but the parameter is left here because /export calls exportStructure() also for other export types which use this parameter

bool $mime

whether to include mime comments

bool $dates

whether to include creation/update/check dates

array $aliases

Aliases of db/table/columns

Return Value

bool

bool exportMetadata(string $db, string|array $tables, array $metadataTypes)

Exports metadata from Configuration Storage

Parameters

string $db

database being exported

string|array $tables

table(s) being exported

array $metadataTypes

types of metadata to export

Return Value

bool

string getTableDefStandIn(string $db, string $view, string $crlf, array $aliases = [])

Returns a stand-in CREATE definition to resolve view dependencies

Parameters

string $db

the database name

string $view

the view name

string $crlf

the end of line sequence

array $aliases

Aliases of db/table/columns

Return Value

string

resulting definition

protected string getTriggers(string $db, string $table)

Outputs triggers

Parameters

string $db

database name

string $table

table name

Return Value

string

Formatted triggers list

protected void init()

Plugin specific initializations.

Return Value

void

PluginPropertyItem getProperties()

Gets the export specific format plugin properties

Return Value

PluginPropertyItem

protected ExportPluginProperties setProperties()

Sets the export plugins properties and is implemented by each export plugin.

Return Value

ExportPluginProperties

void initAlias(array $aliases, string $db, string $table = null)

Initialize aliases

Parameters

array $aliases

Alias information for db/table/column

string $db

the database

string $table

the table

Return Value

void

string getAlias(array $aliases, string $id, string $type = 'dbtblcol', string $db = '', string $tbl = '')

Search for alias of a identifier.

Parameters

array $aliases

Alias information for db/table/column

string $id

the identifier to be searched

string $type

db/tbl/col or any combination of them representing what to be searched

string $db

the database in which search is to be done

string $tbl

the table in which search is to be done

Return Value

string

alias of the identifier if found or ''

string getRelationString(array $foreigners, string $fieldName, string $db, array $aliases = [])

Gives the relation string and also substitutes with alias if required in this format: [Foreign Table] ([Foreign Field])

Parameters

array $foreigners

the foreigners array

string $fieldName

the field name

string $db

the field name

array $aliases

Alias information for db/table/column

Return Value

string

the Relation string

bool isAvailable()

No description

Return Value

bool

string getName()

No description

Return Value

string

protected string exportRoutineSQL(string $db, array $aliases, string $type, string $name, array $routines, string $delimiter)

Generates SQL for routines export

Parameters

string $db Database
array $aliases

Aliases of db/table/columns

string $type

Type of exported routine

string $name

Verbose name of exported routine

array $routines

List of routines to export

string $delimiter

Delimiter to use in SQL

Return Value

string

SQL query

string getTableDef(string $db, string $table, string $crlf, string $errorUrl, bool $showDates = false, bool $addSemicolon = true, bool $view = false, bool $updateIndexesIncrements = true, array $aliases = [])

Returns $table's CREATE definition

Parameters

string $db

the database name

string $table

the table name

string $crlf

the end of line sequence

string $errorUrl

the url to go back in case of error

bool $showDates

whether to include creation/ update/check dates

bool $addSemicolon

whether to add semicolon and end-of-line at the end

bool $view

whether we're handling a view

bool $updateIndexesIncrements

whether we need to update two global variables

array $aliases

Aliases of db/table/columns

Return Value

string

resulting schema

string replaceWithAliases(string $sqlQuery, array $aliases, string $db, string $table = '', string $flag = null)

replaces db/table/column names with their aliases

Parameters

string $sqlQuery

SQL query in which aliases are to be substituted

array $aliases

Alias information for db/table/column

string $db

the database name

string $table

the tablename

string $flag

the flag denoting whether any replacement was done

Return Value

string

query replaced with aliases

protected string generateComment(string $crlf, string|null $sqlStatement, string $comment1, string $comment2, string $tableAlias, string $compat)

Generate comment

Parameters

string $crlf

Carriage return character

string|null $sqlStatement

SQL statement

string $comment1

Comment for dumped table

string $comment2

Comment for current table

string $tableAlias

Table alias

string $compat

Compatibility mode

Return Value

string