Import
class Import (View source)
Library that provides common import functions that are used by import plugins
Methods
No description
Checks whether timeout is getting close
Runs query inside import buffer. This is needed to allow displaying of last SELECT, SHOW or HANDLER results and similar nice stuff.
Runs query inside import buffer. This is needed to allow displaying of last SELECT, SHOW or HANDLER results and similar nice stuff.
Looks for the presence of USE to possibly change current db
Returns next part of imported file/buffer
Skip possible byte order marks (I do not think we need more charsets, but feel free to add more, you can use wikipedia for reference: https://en.wikipedia.org/wiki/Byte_Order_Mark)
Returns the "Excel" column name (i.e. 1 = "A", 26 = "Z", 27 = "AA", etc.)
Returns the column number based on the Excel name.
No description
Builds and executes SQL statements to create the database and tables as necessary, as well as insert all the data.
No description
Checks if ROLLBACK is possible for a SQL query or not.
Checks if a table is 'InnoDB' or not.
No description
No description
No description
No description
Details
__construct()
No description
bool
checkTimeout()
Checks whether timeout is getting close
void
executeQuery(string $sql, array $sqlData)
Runs query inside import buffer. This is needed to allow displaying of last SELECT, SHOW or HANDLER results and similar nice stuff.
void
runQuery(string $sql, array $sqlData)
Runs query inside import buffer. This is needed to allow displaying of last SELECT, SHOW or HANDLER results and similar nice stuff.
string
lookForUse(string $buffer)
Looks for the presence of USE to possibly change current db
string|bool
getNextChunk(File|null $importHandle = null, int $size = 32768)
Returns next part of imported file/buffer
string
skipByteOrderMarksFromContents(string $contents)
Skip possible byte order marks (I do not think we need more charsets, but feel free to add more, you can use wikipedia for reference: https://en.wikipedia.org/wiki/Byte_Order_Mark)
string
getColumnAlphaName(int $num)
Returns the "Excel" column name (i.e. 1 = "A", 26 = "Z", 27 = "AA", etc.)
This functions uses recursion to build the Excel column name.
The column number (1-26) is converted to the responding ASCII character (A-Z) and returned.
If the column number is bigger than 26 (= num of letters in alphabet), an extra character needs to be added. To find this extra character, the number is divided by 26 and this value is passed to another instance of the same function (hence recursion). In that new instance the number is evaluated again, and if it is still bigger than 26, it is divided again and passed to another instance of the same function. This continues until the number is smaller than 26. Then the last called function returns the corresponding ASCII character to the function that called it. Each time a called function ends an extra character is added to the column name. When the first function is reached, the last character is added and the complete column name is returned.
int
getColumnNumberFromName(string $name)
Returns the column number based on the Excel name.
So "A" = 1, "Z" = 26, "AA" = 27, etc.
Basically this is a base26 (A-Z) to base10 (0-9) conversion. It iterates through all characters in the column name and calculates the corresponding value, based on character value (A = 1, ..., Z = 26) and position in the string.
ColumnType
detectType(ColumnType|null $lastCumulativeType, string|null $cell)
No description
array
analyzeTable(ImportTable $table)
Determines if the column types are int, decimal, or string
void
buildSql(string $dbName, array $tables, array|null $analyses = null, array|null $additionalSql = null, array $sqlData = [])
Builds and executes SQL statements to create the database and tables as necessary, as well as insert all the data.
void
handleRollbackRequest(string $sqlQuery)
No description
bool
checkIfRollbackPossible(string $sqlQuery)
Checks if ROLLBACK is possible for a SQL query or not.
bool
isTableTransactional(string $table)
Checks if a table is 'InnoDB' or not.
static array
getCompressions()
No description
static false|string
getLocalFiles(array $importList)
No description
string
getNextAvailableTableName(string $databaseName, string $proposedTableName)
No description
array
createDatabase(string $dbName, string $charset, string $collation, array $sqlData)
No description