Warning: mysql_connect(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/zurmoorg/public_html/z-header.php on line 8

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/zurmoorg/public_html/z-header.php on line 8

ImportDatabaseUtil Class Reference

Static Public Member Functions

static makeDatabaseTableByFileHandleAndTableName ($fileHandle, $tableName, $delimiter= ',', $enclosure="'", $firstRowIsHeaderRow=false)
static databaseSupportsLoadLocalInFile ()
static getSubset ($tableName, $where=null, $count=null, $offset=null)
static getCount ($tableName, $where=null)
static updateRowAfterProcessing ($tableName, $id, $status, $serializedMessages)
static updateRowValue ($tableName, $id, $attribute, $newValue)
static getReservedColumnNames ()
static createTableByTableNameAndImportColumns ($tableName, array $columns)

Data Fields

const ALLOWED_ENCODINGS_FOR_CONVERSION = 'UTF-8, UTF-7, ASCII, CP1252, ISO-8859-1, EUC-JP, SJIS, eucJP-win, SJIS-win, JIS, ISO-2022-JP'
const MAX_IMPORT_COLUMN_COUNT = 99
const BULK_INSERT_COUNT = 500

Static Protected Member Functions

static createTableByTableNameAndImportCsvIntoTable ($fileHandle, $tableName, $delimiter, $enclosure, $firstRowIsHeaderRow)
static determineMaximumColumnLengthAndPopulateImportArray ($fileHandle, $delimiter, $enclosure, array &$maxLengths, array &$importArray, $firstRowIsHeaderRow)
static convertCurrentValueToUtf8AndPopulateImportDataArray ($k, &$v, array &$importData)
static padEmptyKeys (array &$sourceArray, $newSize, $value=1)
static updateMaxLengthForKey ($k, $v, array &$maxLengths)
static unsetEmptyKeysForKeyIfValueNotEmpty ($k, $v, array &$emptyKeys)
static unsetEmptyKeysFromMaxLengthAndImportArray ($clearEmptyColumns, array $emptyKeys, &$maxLengths, array &$importArray)
static prependEmptyStringToAllImportRows (array &$val)
static resolveColumnsByMaximumColumnLengths (array $maxLengths, array &$columns)
static safeValidateColumnCountAndCreateTable ($tableName, $columnCount, array $columns)
static convertImportArrayAndWriteToTemporaryFile (array $importArray, $firstRowIsHeaderRow)
static convertImportArrayToCsv (array $importArray, $firstRowIsHeaderRow)
static writeCsvToTemporaryFile ($csv)
static fixPermissionsOnTemporaryFile ()
static loadDataFromTemporaryFileToTable ($tableName)
static importArrayIntoTable ($tableName, array &$importArray, array $columnNames)
static padSubArrays (array &$array, $newSize, $value= '')
static geColumnData ($tableName, $column)
static getReservedColumnMetadata ()
static getTableSchemaByNameAndImportColumns ($tableName, array $columns, $withReservedColumns=true)

Static Protected Attributes

static $temporaryFileName = null
static $importDataRowCount = null

Detailed Description

Helper class for working with import data tables.

Definition at line 40 of file ImportDatabaseUtil.php.


Member Function Documentation

static makeDatabaseTableByFileHandleAndTableName ( fileHandle,
tableName,
delimiter = ',',
enclosure = "'",
firstRowIsHeaderRow = false 
) [static]

Given a file resource, convert the file into a database table based on the table name provided. Assumes the file is a csv.

Parameters:
object $fileHandle
string $tableName
string $delimiter
string $enclosure
bool $firstRowIsHeaderRow
Returns:
bool

Definition at line 62 of file ImportDatabaseUtil.php.

static determineMaximumColumnLengthAndPopulateImportArray ( fileHandle,
delimiter,
enclosure,
array &$  maxLengths,
array &$  importArray,
firstRowIsHeaderRow 
) [static, protected]

Populates maxLengths with the max lengths of columns and importArray with converted utf8 data

Parameters:
$fileHandle 
$delimiter 
$enclosure 
$maxLengths 
$importArray 
$firstRowIsHeaderRow 

Definition at line 115 of file ImportDatabaseUtil.php.

static convertCurrentValueToUtf8AndPopulateImportDataArray ( k,
&$  v,
array &$  importData 
) [static, protected]

Convert current value to utf8, in place. Populates values into provided array at k position

Parameters:
$k 
$v 
$importData 

Definition at line 142 of file ImportDatabaseUtil.php.

static padEmptyKeys ( array &$  sourceArray,
newSize,
value = 1 
) [static, protected]

Pad the sourceArray upto newSize with provided value

Parameters:
$sourceArray 
$newSize 
int $value

Definition at line 159 of file ImportDatabaseUtil.php.

static updateMaxLengthForKey ( k,
v,
array &$  maxLengths 
) [static, protected]

Updates maxLengths array for k if provided v is of greater length

Parameters:
$k 
$v 
$maxLengths 

Definition at line 174 of file ImportDatabaseUtil.php.

static unsetEmptyKeysForKeyIfValueNotEmpty ( k,
v,
array &$  emptyKeys 
) [static, protected]

Unsets key if the provided value is not empty

Parameters:
$k 
$v 
$emptyKeys 

Definition at line 189 of file ImportDatabaseUtil.php.

static unsetEmptyKeysFromMaxLengthAndImportArray ( clearEmptyColumns,
array $  emptyKeys,
&$  maxLengths,
array &$  importArray 
) [static, protected]

Unsets the keys that always remain empty from importArray and maxLengths

Parameters:
$clearEmptyColumns 
$emptyKeys 
$maxLengths 
$importArray 

Definition at line 205 of file ImportDatabaseUtil.php.

static prependEmptyStringToAllImportRows ( array &$  val  )  [static, protected]

Prepends an empty string to provided $val

Parameters:
$val 
Exceptions:
NotSupportedException 

Definition at line 226 of file ImportDatabaseUtil.php.

static databaseSupportsLoadLocalInFile (  )  [static]

Check whether db supports load local infile or not. public due to usage in benchmarks

Returns:
bool

Definition at line 240 of file ImportDatabaseUtil.php.

static resolveColumnsByMaximumColumnLengths ( array $  maxLengths,
array &$  columns 
) [static, protected]

Resolves string columns for given max lengths

Parameters:
$maxLengths 
$columns 
Returns:
int column count

Definition at line 257 of file ImportDatabaseUtil.php.

static safeValidateColumnCountAndCreateTable ( tableName,
columnCount,
array $  columns 
) [static, protected]

Validates if columnCount is within allowed range, and creates table if its not.

Parameters:
$tableName 
$columnCount 
$columns 
Exceptions:
TooManyColumnsFailedException 

Definition at line 281 of file ImportDatabaseUtil.php.

static convertImportArrayAndWriteToTemporaryFile ( array $  importArray,
firstRowIsHeaderRow 
) [static, protected]

Writes provided array as csv to a temporary file

Parameters:
$importArray 
$firstRowIsHeaderRow 
Exceptions:
NotSupportedException 

Definition at line 300 of file ImportDatabaseUtil.php.

static convertImportArrayToCsv ( array $  importArray,
firstRowIsHeaderRow 
) [static, protected]

Converts import array to csv

Parameters:
$importArray 
$firstRowIsHeaderRow 
Returns:
string

Definition at line 319 of file ImportDatabaseUtil.php.

static writeCsvToTemporaryFile ( csv  )  [static, protected]

Writes csv data to temporary file while ensuring utf-8 special characters remain unchanged

Parameters:
$csv 
Exceptions:
NotSupportedException 

Definition at line 335 of file ImportDatabaseUtil.php.

static fixPermissionsOnTemporaryFile (  )  [static, protected]

Fixes permissions on temporary file to 777

Exceptions:
NotSupportedException 

Definition at line 350 of file ImportDatabaseUtil.php.

static loadDataFromTemporaryFileToTable ( tableName  )  [static, protected]

loads data from provided csv file to mysql using LOAD DATA INFILE

Parameters:
$tableName 
Exceptions:
NotSupportedException 

Definition at line 364 of file ImportDatabaseUtil.php.

static importArrayIntoTable ( tableName,
array &$  importArray,
array $  columnNames 
) [static, protected]

Imports data from array to table

Parameters:
$tableName 
$importArray 
$columnNames 
Exceptions:
NotSupportedException 

Definition at line 403 of file ImportDatabaseUtil.php.

static padSubArrays ( array &$  array,
newSize,
value = '' 
) [static, protected]

Pads subArrays with given value

Parameters:
array $array
$padSize 
string $value

Definition at line 424 of file ImportDatabaseUtil.php.

static getSubset ( tableName,
where = null,
count = null,
offset = null 
) [static]

Given a table name, count, and offset get an array of beans.

Parameters:
string $tableName
integer $count
integer $offset
Returns:
array of RedBean_OODBBean beans.

Definition at line 445 of file ImportDatabaseUtil.php.

static getCount ( tableName,
where = null 
) [static]

Get the row count in a given table.

Parameters:
string $tableName
Returns:
integer

Definition at line 472 of file ImportDatabaseUtil.php.

static updateRowAfterProcessing ( tableName,
id,
status,
serializedMessages 
) [static]

Update the row in the table with status and message information after the row is attempted or successfully imported.

Parameters:
string $tableName
integer $id
integer $status
string or null $serializedMessages

Definition at line 500 of file ImportDatabaseUtil.php.

static updateRowValue ( tableName,
id,
attribute,
newValue 
) [static]

Update the row value in the table with a new value

Parameters:
string $tableName
integer $id
string $attribute
string|null $newValue
Exceptions:
NotFoundException 
FailedToSaveModelException 

Definition at line 530 of file ImportDatabaseUtil.php.

static getReservedColumnNames (  )  [static]

For the temporary import tables, some of the columns are reserved and not used by any of the import data coming from a csv.

Returns:
array of column names.

Definition at line 595 of file ImportDatabaseUtil.php.

static getTableSchemaByNameAndImportColumns ( tableName,
array $  columns,
withReservedColumns = true 
) [static, protected]

Returns table schema definition for temporary import table provided name and columns, implicitly adds reserved columns too

Parameters:
$tableName 
$columns $withReservedColumns
Returns:
array

Definition at line 638 of file ImportDatabaseUtil.php.

static createTableByTableNameAndImportColumns ( tableName,
array $  columns 
) [static]

Creates table in db give table name and import columns Public due to import/DemoController

Parameters:
$tableName 
$columns 

Definition at line 653 of file ImportDatabaseUtil.php.


The documentation for this class was generated from the following file:
 All Data Structures Functions Variables
Generated on Wed Feb 20 07:10:50 2019

Warning: mysql_connect(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/zurmoorg/public_html/z-footer.php on line 8

Deprecated: mysql_connect(): The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in /home/zurmoorg/public_html/z-footer.php on line 8