Import
class Import (View source)
Library that provides common import functions that are used by import plugins
Constants
NONE |
|
VARCHAR |
|
INT |
|
DECIMAL |
|
BIGINT |
|
GEOMETRY |
|
M |
|
D |
|
FULL |
|
TBL_NAME |
|
COL_NAMES |
|
ROWS |
|
TYPES |
|
SIZES |
|
FORMATTEDSQL |
|
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.
Obtains the precision (total # of digits) from a size of type decimal
Obtains the scale (# of digits to the right of the decimal point) from a size of type decimal
Obtains the decimal size of a given cell
Obtains the size of the given cell
Determines what MySQL type a cell is
Determines if the column types are int, decimal, or string
Builds and executes SQL statements to create the database and tables as necessary, as well as insert all the data.
Handles request for ROLLBACK.
Checks if ROLLBACK is possible for a SQL query or not.
Checks if a table is 'InnoDB' or not.
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.
array
lookForUse(string|null $buffer, string|null $db, bool|null $reload)
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.
int
getDecimalPrecision(string $lastCumulativeSize)
Obtains the precision (total # of digits) from a size of type decimal
int
getDecimalScale(string $lastCumulativeSize)
Obtains the scale (# of digits to the right of the decimal point) from a size of type decimal
array
getDecimalSize(string $cell)
Obtains the decimal size of a given cell
string|int
detectSize(string|int $lastCumulativeSize, int|null $lastCumulativeType, int $currentCellType, string $cell)
Obtains the size of the given cell
int
detectType(int|null $lastCumulativeType, string|null $cell)
Determines what MySQL type a cell is
array|bool
analyzeTable(array $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, bool $createDb = true, array|null $options = 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)
Handles request for ROLLBACK.
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