Documentation

GRIS_IMPORT
in package

Class to manage imports

With this class imports can be managed

PHP version 8

Copyright (c) 2024, Holger Heuser, GESIS Leibniz Institute for the Social Sciences Unter Sachsenhausen 6-8 50667 Cologne, Germany

Tags
copyright

Copyright (c) 2024, Holger Heuser, GESIS Leibniz Institute for the Social Sciences

link

GESIS Leibniz Institute for the Social Sciences

since

File available since Release 4.6

version
1.0
author

Holger Heuser holger.heuser@gesis.org

Table of Contents

dbtable  = 'gris_import'
The constant for the database table
settings_group  = "import"
The constant for the settings group
$classname  : object
The name of the class
$dbconnection  : object
The database object for managing the connection
$i18n  : object
The object for translations
$import  : object
The object for institutes
$settings  : object
The object for settings
$state  : object
The object for logs
__construct()  : mixed
The class constructor
get_import_list()  : array<string|int, mixed>
Returns a list of data for all stored imports (or optional for a single import identified by its ID)
parse_csv()  : mixed
Parse CSV files
parse_json()  : mixed
Parse XML files
parse_xml()  : mixed
Parse JSON files
set_import()  : Returns
Create a new import

Constants

dbtable

The constant for the database table

public mixed dbtable = 'gris_import'

settings_group

The constant for the settings group

public mixed settings_group = "import"

Properties

$classname

The name of the class

protected object $classname = NULL
Tags
access

private

$dbconnection

The database object for managing the connection

private object $dbconnection = NULL
Tags
access

private

$i18n

The object for translations

private object $i18n
Tags
access

private

$import

The object for institutes

private object $import = array()
Tags
access

private

$settings

The object for settings

private object $settings = null
Tags
access

private

$state

The object for logs

private object $state
Tags
access

private

Methods

__construct()

The class constructor

public __construct() : mixed

Initializes the objects

Return values
mixed

get_import_list()

Returns a list of data for all stored imports (or optional for a single import identified by its ID)

public get_import_list([int $id = NULL ][, bool $short = false ]) : array<string|int, mixed>
Parameters
$id : int = NULL

The import ID (to filter a special import)

$short : bool = false

Return only the short version (name => ID with flag)

Return values
array<string|int, mixed>

Returns the data of the imports (or of a single import)

parse_csv()

Parse CSV files

public parse_csv(string $filename, string $separator) : mixed
Parameters
$filename : string

The name of the file to parse

$separator : string

The separator

Return values
mixed

Returns the array with the csv data oder false on error

parse_json()

Parse XML files

public parse_json(string $filename) : mixed
Parameters
$filename : string

The name of the file to parse

Return values
mixed

Returns the array with the json data oder false on error

parse_xml()

Parse JSON files

public parse_xml(string $filename) : mixed
Parameters
$filename : string

The name of the file to parse

Return values
mixed

Returns the array with the json data oder false on error

set_import()

Create a new import

public set_import(array<string|int, mixed> $data) : Returns

$data = array( "gris_import_id" => int (if empty, a new import will be created) "gris_import_name" => string "gris_import_source" => string ("file"/URL) "gris_import_username" => string "gris_import_password" => string "gris_import_object" => string (resource|project) "gris_import_preprocess" => string "gris_import_description" => string )

Parameters
$data : array<string|int, mixed>

The import data (only update if ID)

Return values
Returns

the current ID on success and false on error

Search results