class JSONToSQLConverter

This class allows the conversion of a json-schema.org compliant JSON database and exported from G6K to a SQL database

Properties

private array $parameters
private array $datatypes
private string $databasesDir
private Database $database

Methods

void
__construct(array $fparameters, string $databasesDir)

Constructor of class JSONToSQLConverter

string
getType(stdClass $coldef)

Returns the data type of a database column

string
getValue(string $type, string $value)

Prepares a value according to its type for its insertion in a SQL database

properties(string $arg)

Decodes a properties list from JSON schema

void
connectDatabase(string $dbschema, string $dbtype)

Connects to the database

array
convert(string $name, string $schemafile, string $datafile)

Imports a JSON database to a SQL database and returns an array descriptor of the database for the update of DataSources.xml

Details

at line 116
void __construct(array $fparameters, string $databasesDir)

Constructor of class JSONToSQLConverter

Parameters

array $fparameters The database parameters
string $databasesDir The G6K databases directory

Return Value

void

at line 129
private string getType(stdClass $coldef)

Returns the data type of a database column

Parameters

stdClass $coldef The database column definition

Return Value

string The data type

at line 156
private string getValue(string $type, string $value)

Prepares a value according to its type for its insertion in a SQL database

Parameters

string $type The type of the value
string $value The value

Return Value

string The new value

at line 175
private stdClass properties(string $arg)

Decodes a properties list from JSON schema

Parameters

string $arg The properties list

Return Value

stdClass The decoded properties

at line 194
private void connectDatabase(string $dbschema, string $dbtype)

Connects to the database

Parameters

string $dbschema The database name
string $dbtype The database type

Return Value

void

at line 222
array convert(string $name, string $schemafile, string $datafile)

Imports a JSON database to a SQL database and returns an array descriptor of the database for the update of DataSources.xml

Parameters

string $name The name of the database
string $schemafile The JSON schema file
string $datafile The JSON data file

Return Value

array The array descriptor of the SQL database

Exceptions

Exception