PHP Класс Horde_Data_Csv, horde

Copyright 1999-2016 Horde LLC (http://www.horde.org/) See the enclosed file COPYING for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.
Автор: Jan Schneider ([email protected])
Автор: Chuck Hagenbuch ([email protected])
Наследование: extends Horde_Data_Base
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$_contentType string MIME content type.
$_extension string File extension.

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

Метод Описание
exportData ( array $data, boolean $header = false, $export_mapping = [] ) : string Builds a CSV file from a given data structure and returns it as a string.
exportFile ( string $filename, array $data, boolean $header = false, $export_mapping = [] ) Builds a CSV file from a given data structure and triggers its download. It DOES NOT exit the current script but only outputs the correct headers and data.
getCsv ( resource $file, array $params = [] ) : array | boolean Wrapper around fgetcsv().
importFile ( string $filename, boolean $header = false, string $sep = ',', string $quote = '', integer $fields = null, $import_mapping = [], string $charset = null, string $crlf = null ) : array Imports and parses a CSV file.
nextStep ( integer $action, array $param = [] ) : mixed Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.

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

exportData() публичный Метод

Builds a CSV file from a given data structure and returns it as a string.
public exportData ( array $data, boolean $header = false, $export_mapping = [] ) : string
$data array A two-dimensional array containing the data set.
$header boolean If true, the rows of $data are associative arrays with field names as their keys.
Результат string The CSV data.

exportFile() публичный Метод

Builds a CSV file from a given data structure and triggers its download. It DOES NOT exit the current script but only outputs the correct headers and data.
public exportFile ( string $filename, array $data, boolean $header = false, $export_mapping = [] )
$filename string The name of the file to be downloaded.
$data array A two-dimensional array containing the data set.
$header boolean If true, the rows of $data are associative arrays with field names as their keys.

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

Empty lines will be skipped. If the 'length' parameter is provided, all rows are filled up with empty strings up to this length, or stripped down to this length.
public static getCsv ( resource $file, array $params = [] ) : array | boolean
$file resource A file pointer.
$params array Optional parameters. Possible values: - escape: The escape character. - length: The expected number of fields. - quote: The quote character. - separator: The field delimiter.
Результат array | boolean A row from the CSV file or false on error or end of file.

importFile() публичный Метод

Imports and parses a CSV file.
public importFile ( string $filename, boolean $header = false, string $sep = ',', string $quote = '', integer $fields = null, $import_mapping = [], string $charset = null, string $crlf = null ) : array
$filename string The name of the file to parse.
$header boolean Does the first line contain the field/column names?
$sep string The field/column separator.
$quote string The quoting character.
$fields integer The number or fields/columns.
$charset string The file's charset.
$crlf string The file's linefeed characters.
Результат array A two-dimensional array of all imported data rows. If $header was true the rows are associative arrays with the field/column names as the keys.

nextStep() публичный Метод

Takes all necessary actions for the given import step, parameters and form values and returns the next necessary step.
public nextStep ( integer $action, array $param = [] ) : mixed
$action integer The current step. One of the IMPORT_* constants.
$param array An associative array containing needed parameters for the current step. Keys for this driver: - check_charset: (boolean) Do some checks to see if the correct charset has been provided. Throws charset exception on error. - import_mapping: TODO
Результат mixed Either the next step as an integer constant or imported data set after the final step.

Описание свойств

$_contentType защищенное свойство

MIME content type.
protected string $_contentType
Результат string

$_extension защищенное свойство

File extension.
protected string $_extension
Результат string