TYPO3 CMS  TYPO3_7-6
TYPO3\CMS\Install\Service\SqlSchemaMigrationService Class Reference

Public Member Functions

 setDeletedPrefixKey ($prefix)
 
 getDeletedPrefixKey ()
 
 getFieldDefinitions_fileContent ($fileContent)
 
 getCollationForCharset ($charset)
 
 getFieldDefinitions_database ()
 
 getDatabaseExtra ($FDsrc, $FDcomp, $onlyTableList='', $ignoreNotNullWhenComparing=false)
 
 getUpdateSuggestions ($diffArr, $keyList='extra, diff')
 
 assembleFieldDefinition ($row)
 
 getStatementArray ($sqlcode, $removeNonSQL=false, $query_regex='')
 
 getCreateTables ($statements, $insertCountFlag=false)
 
 getTableInsertStatements ($statements, $table)
 
 performUpdateQueries ($arr, $keyArr)
 
 getListOfTables ()
 

Public Attributes

const MYSQL_MAXIMUM_FIELD_WIDTH = 64
 

Protected Member Functions

 isDbalEnabled ()
 
 getDatabaseConnection ()
 

Protected Attributes

 $deletedPrefixKey = 'zzz_deleted_'
 
 $character_sets = []
 

Detailed Description

Verify TYPO3 DB table structure. Mainly used in install tool compare wizard and extension manager.

Definition at line 21 of file SqlSchemaMigrationService.php.

Member Function Documentation

◆ assembleFieldDefinition()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::assembleFieldDefinition (   $row)

Converts a result row with field information into the SQL field definition string

Parameters
array$rowMySQL result row
Returns
string Field definition

Definition at line 511 of file SqlSchemaMigrationService.php.

Referenced by TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getFieldDefinitions_database().

◆ getCollationForCharset()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getCollationForCharset (   $charset)

Look up the default collation for specified character set based on "SHOW CHARACTER SET" output

Parameters
string$charsetCharacter set
Returns
string Corresponding default collation

Definition at line 156 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseConnection().

Referenced by TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getFieldDefinitions_fileContent().

◆ getCreateTables()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getCreateTables (   $statements,
  $insertCountFlag = false 
)

Returns tables to create and how many records in each

Parameters
array$statementsArray of SQL statements to analyse.
bool$insertCountFlagIf set, will count number of INSERT INTO statements following that table definition
Returns
array Array with table definitions in index 0 and count in index 1

Definition at line 583 of file SqlSchemaMigrationService.php.

◆ getDatabaseConnection()

◆ getDatabaseExtra()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getDatabaseExtra (   $FDsrc,
  $FDcomp,
  $onlyTableList = '',
  $ignoreNotNullWhenComparing = false 
)

Compares two arrays with field information and returns information about fields that are MISSING and fields that have CHANGED. FDsrc and FDcomp can be switched if you want the list of stuff to remove rather than update.

Parameters
array$FDsrcField definitions, source (from getFieldDefinitions_fileContent())
array$FDcompField definitions, comparison. (from getFieldDefinitions_database())
string$onlyTableListTable names (in list) which is the ONLY one observed.
bool$ignoreNotNullWhenComparingIf set, this function ignores NOT NULL statements of the SQL file field definition when comparing current field definition from database with field definition from SQL file. This way, NOT NULL statements will be executed when the field is initially created, but the SQL parser will never complain about missing NOT NULL statements afterwards.
Returns
array Returns an array with 1) all elements from $FDsrc that is not in $FDcomp (in key 'extra') and 2) all elements from $FDsrc that is different from the ones in $FDcomp

Definition at line 255 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseConnection(), TYPO3\CMS\Core\Utility\GeneralUtility\inList(), and TYPO3\CMS\Install\Service\SqlSchemaMigrationService\isDbalEnabled().

◆ getDeletedPrefixKey()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getDeletedPrefixKey ( )

Get prefix of deleted tables

Returns
string

Definition at line 53 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\$deletedPrefixKey.

◆ getFieldDefinitions_database()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getFieldDefinitions_database ( )

Reads the field definitions for the current database

Returns
array Array with information about table.

Definition at line 180 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\assembleFieldDefinition(), and TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseConnection().

◆ getFieldDefinitions_fileContent()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getFieldDefinitions_fileContent (   $fileContent)

Reads the field definitions for the input SQL-file string

Parameters
string$fileContentShould be a string read from an SQL-file made with 'mysqldump [database_name] -d'
Returns
array Array with information about table.

Definition at line 64 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getCollationForCharset(), TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseConnection(), and TYPO3\CMS\Core\Utility\GeneralUtility\trimExplode().

◆ getListOfTables()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getListOfTables ( )

Returns list of tables in the database

Returns
array List of tables.
See also
::admin_get_tables()

Definition at line 671 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseConnection().

◆ getStatementArray()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getStatementArray (   $sqlcode,
  $removeNonSQL = false,
  $query_regex = '' 
)

Returns an array where every entry is a single SQL-statement. Input must be formatted like an ordinary MySQL-dump files.

Parameters
string$sqlcodeThe SQL-file content. Provided that 1) every query in the input is ended with ';' and that a line in the file contains only one query or a part of a query.
bool$removeNonSQLIf set, non-SQL content (like comments and blank lines) is not included in the final output
string$query_regexRegex to filter SQL lines to include
Returns
array Array of SQL statements

Definition at line 544 of file SqlSchemaMigrationService.php.

◆ getTableInsertStatements()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getTableInsertStatements (   $statements,
  $table 
)

Extracts all insert statements from $statement array where content is inserted into $table

Parameters
array$statementsArray of SQL statements
string$tableTable name
Returns
array Array of INSERT INTO statements where table match $table

Definition at line 620 of file SqlSchemaMigrationService.php.

◆ getUpdateSuggestions()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::getUpdateSuggestions (   $diffArr,
  $keyList = 'extra,
diff'   
)

Returns an array with SQL-statements that is needed to update according to the diff-array

Parameters
array$diffArrArray with differences of current and needed DB settings. (from getDatabaseExtra())
string$keyListList of fields in diff array to take notice of.
Returns
array Array of SQL statements (organized in keys depending on type)

Definition at line 347 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\$deletedPrefixKey, TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseConnection(), and TYPO3\CMS\Install\Service\SqlSchemaMigrationService\isDbalEnabled().

◆ isDbalEnabled()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::isDbalEnabled ( )
protected

Checks if DBAL is enabled for the database connection

Returns
bool

Definition at line 686 of file SqlSchemaMigrationService.php.

Referenced by TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseExtra(), and TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getUpdateSuggestions().

◆ performUpdateQueries()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::performUpdateQueries (   $arr,
  $keyArr 
)

Performs the queries passed from the input array.

Parameters
array$arrArray of SQL queries to execute.
array$keyArrArray with keys that must match keys in $arr. Only where a key in this array is set and TRUE will the query be executed (meant to be passed from a form checkbox)
Returns
mixed Array with error message from database if any occurred. Otherwise TRUE if everything was executed successfully.

Definition at line 642 of file SqlSchemaMigrationService.php.

References TYPO3\CMS\Install\Service\SqlSchemaMigrationService\getDatabaseConnection().

◆ setDeletedPrefixKey()

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::setDeletedPrefixKey (   $prefix)

Set prefix of deleted tables

Parameters
string$prefixPrefix string

Definition at line 43 of file SqlSchemaMigrationService.php.

Member Data Documentation

◆ $character_sets

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::$character_sets = []
protected

Definition at line 36 of file SqlSchemaMigrationService.php.

◆ $deletedPrefixKey

TYPO3\CMS\Install\Service\SqlSchemaMigrationService::$deletedPrefixKey = 'zzz_deleted_'
protected

◆ MYSQL_MAXIMUM_FIELD_WIDTH

const TYPO3\CMS\Install\Service\SqlSchemaMigrationService::MYSQL_MAXIMUM_FIELD_WIDTH = 64

Maximum field width of MySQL

Definition at line 26 of file SqlSchemaMigrationService.php.