All Classes Namespaces Files Functions Variables Pages
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


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 25 of file SqlSchemaMigrationService.php.

Member Function Documentation

assembleFieldDefinition (   $row)

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

array$rowMySQL result row
string Field definition

Definition at line 503 of file SqlSchemaMigrationService.php.

Referenced by SqlSchemaMigrationService\getFieldDefinitions_database().

getCollationForCharset (   $charset)

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

string$charsetCharacter set
string Corresponding default collation

Definition at line 160 of file SqlSchemaMigrationService.php.

References GeneralUtility\makeInstance().

Referenced by SqlSchemaMigrationService\getFieldDefinitions_fileContent().

getCreateTables (   $statements,
  $insertCountFlag = false 

Returns tables to create and how many records in each

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

Definition at line 575 of file SqlSchemaMigrationService.php.

getDatabaseExtra (   $FDsrc,
  $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.

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.
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 268 of file SqlSchemaMigrationService.php.

References GeneralUtility\inList().

getDeletedPrefixKey ( )

Get prefix of deleted tables


Definition at line 57 of file SqlSchemaMigrationService.php.

References SqlSchemaMigrationService\$deletedPrefixKey.

getFieldDefinitions_database ( )

Reads the field definitions for the current database

array Array with information about table.

Definition at line 183 of file SqlSchemaMigrationService.php.

References SqlSchemaMigrationService\assembleFieldDefinition(), and GeneralUtility\makeInstance().

getFieldDefinitions_fileContent (   $fileContent)

Reads the field definitions for the input SQL-file string

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

Definition at line 68 of file SqlSchemaMigrationService.php.

References SqlSchemaMigrationService\getCollationForCharset(), and GeneralUtility\trimExplode().

getListOfTables ( )

Returns list of tables in the database

array List of tables.
See also

Definition at line 662 of file SqlSchemaMigrationService.php.

References GeneralUtility\makeInstance().

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.

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
array Array of SQL statements

Definition at line 536 of file SqlSchemaMigrationService.php.

getTableInsertStatements (   $statements,

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

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

Definition at line 612 of file SqlSchemaMigrationService.php.

getUpdateSuggestions (   $diffArr,
  $keyList = 'extra,

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

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

Definition at line 338 of file SqlSchemaMigrationService.php.

References SqlSchemaMigrationService\$deletedPrefixKey, and GeneralUtility\makeInstance().

performUpdateQueries (   $arr,

Performs the queries passed from the input array.

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)
mixed Array with error message from database if any occurred. Otherwise TRUE if everything was executed successfully.

Definition at line 634 of file SqlSchemaMigrationService.php.

References GeneralUtility\makeInstance().

setDeletedPrefixKey (   $prefix)

Set prefix of deleted tables

string$prefixPrefix string

Definition at line 47 of file SqlSchemaMigrationService.php.

Member Data Documentation

$character_sets = []

Definition at line 40 of file SqlSchemaMigrationService.php.

$deletedPrefixKey = 'zzz_deleted_'

Maximum field width of MySQL

Definition at line 30 of file SqlSchemaMigrationService.php.