PHP Класс Piwik\Db\BatchInsert

Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
createTableFromCSVFile ( string $tableName, array $fields, string $filePath, array $fileSpec ) : boolean Batch insert into table from CSV (or other delimited) file.
tableInsertBatch ( string $tableName, array $fields, array $values, boolean $throwException = false, string $charset = 'utf8' ) : boolean Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs, as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
tableInsertBatchIterate ( string $tableName, array $fields, array $values, boolean $ignoreWhenDuplicate = true ) Performs a batch insert into a specific table by iterating through the data

Защищенные методы

Метод Описание
createCSVFile ( string $filePath, array $fileSpec, array $rows ) Create CSV (or other delimited) files

Приватные методы

Метод Описание
getBestPathForLoadData ( )

Описание методов

createCSVFile() защищенный статический Метод

Create CSV (or other delimited) files
protected static createCSVFile ( string $filePath, array $fileSpec, array $rows )
$filePath string filename to create
$fileSpec array File specifications (delimiter, line terminator, etc)
$rows array Array of array corresponding to rows of values

createTableFromCSVFile() публичный статический Метод

Batch insert into table from CSV (or other delimited) file.
public static createTableFromCSVFile ( string $tableName, array $fields, string $filePath, array $fileSpec ) : boolean
$tableName string Name of table
$fields array Field names
$filePath string Path name of a file.
$fileSpec array File specifications (delimiter, line terminator, etc)
Результат boolean True if successful; false otherwise

tableInsertBatch() публичный статический Метод

Performs a batch insert into a specific table using either LOAD DATA INFILE or plain INSERTs, as a fallback. On MySQL, LOAD DATA INFILE is 20x faster than a series of plain INSERTs.
public static tableInsertBatch ( string $tableName, array $fields, array $values, boolean $throwException = false, string $charset = 'utf8' ) : boolean
$tableName string PREFIXED table name! you must call Common::prefixTable() before passing the table name
$fields array array of unquoted field names
$values array array of data to be inserted
$throwException boolean Whether to throw an exception that was caught while trying LOAD DATA INFILE, or not.
$charset string The charset to use, defaults to utf8
Результат boolean True if the bulk LOAD was used, false if we fallback to plain INSERTs

tableInsertBatchIterate() публичный статический Метод

NOTE: you should use tableInsertBatch() which will fallback to this function if LOAD DATA INFILE not available
public static tableInsertBatchIterate ( string $tableName, array $fields, array $values, boolean $ignoreWhenDuplicate = true )
$tableName string PREFIXED table name! you must call Common::prefixTable() before passing the table name
$fields array array of unquoted field names
$values array array of data to be inserted
$ignoreWhenDuplicate boolean Ignore new rows that contain unique key values that duplicate old rows