FacturaScripts

DataBaseTools
in package

This class allows to read and check the required structure for the database tables

Tags
author

Carlos Garcia Gomez [email protected]

Table of Contents

$dataBase  : DataBase
DataBase object.
checkTable()  : string
Checks and compares the database table structure with the xml definition.
generateTable()  : string
Creates the database table with the provided structure.
getXmlTable()  : bool
Extracts columns and constraints form the XML definition.
getXmlTableLocation()  : string
Returns the full file path for table XML file.
checkXmlColumns()  : mixed
Updates names and types for each column.
checkXmlConstraints()  : mixed
Updates names and constraints for each constraint.
compareColumns()  : string
Compares two arrays of columns, returns a SQL statement if there are differences.
compareConstraints()  : string
Compares two arrays of constraints, returns a SQL statement if there are differences.
compareDataTypes()  : bool
Compares data types from a column. Returns True if they are the same.
dataBase()  : DataBase
searchInArray()  : array<string|int, mixed>
Look for a column with a value by his name in array.
sql()  : DataBaseQueries

Properties

Methods

checkTable()

Checks and compares the database table structure with the xml definition.

public static checkTable(string $tableName, array<string|int, mixed> $xmlCols, array<string|int, mixed> $xmlCons) : string

Returns a SQL statement if there are differences.

Parameters
$tableName : string
$xmlCols : array<string|int, mixed>
$xmlCons : array<string|int, mixed>
Return values
string

generateTable()

Creates the database table with the provided structure.

public static generateTable(string $tableName, array<string|int, mixed> $xmlCols, array<string|int, mixed> $xmlCons) : string
Parameters
$tableName : string
$xmlCols : array<string|int, mixed>
$xmlCons : array<string|int, mixed>
Return values
string

getXmlTable()

Extracts columns and constraints form the XML definition.

public static getXmlTable(string $tableName, array<string|int, mixed> &$columns, array<string|int, mixed> &$constraints) : bool
Parameters
$tableName : string
$columns : array<string|int, mixed>
$constraints : array<string|int, mixed>
Return values
bool

getXmlTableLocation()

Returns the full file path for table XML file.

public static getXmlTableLocation(string $tableName) : string
Parameters
$tableName : string
Return values
string

checkXmlColumns()

Updates names and types for each column.

private static checkXmlColumns(array<string|int, mixed> &$columns, SimpleXMLElement $xml) : mixed
Parameters
$columns : array<string|int, mixed>
$xml : SimpleXMLElement
Return values
mixed

checkXmlConstraints()

Updates names and constraints for each constraint.

private static checkXmlConstraints(array<string|int, mixed> &$constraints, SimpleXMLElement $xml) : mixed
Parameters
$constraints : array<string|int, mixed>
$xml : SimpleXMLElement
Return values
mixed

compareColumns()

Compares two arrays of columns, returns a SQL statement if there are differences.

private static compareColumns(string $tableName, array<string|int, mixed> $xmlCols, array<string|int, mixed> $dbCols) : string
Parameters
$tableName : string
$xmlCols : array<string|int, mixed>
$dbCols : array<string|int, mixed>
Return values
string

compareConstraints()

Compares two arrays of constraints, returns a SQL statement if there are differences.

private static compareConstraints(string $tableName, array<string|int, mixed> $xmlCons, array<string|int, mixed> $dbCons) : string
Parameters
$tableName : string
$xmlCons : array<string|int, mixed>
$dbCons : array<string|int, mixed>
Return values
string

compareDataTypes()

Compares data types from a column. Returns True if they are the same.

private static compareDataTypes(string $dbType, string $xmlType) : bool
Parameters
$dbType : string
$xmlType : string
Return values
bool

searchInArray()

Look for a column with a value by his name in array.

private static searchInArray(array<string|int, mixed> $items, string $index, string $value) : array<string|int, mixed>
Parameters
$items : array<string|int, mixed>
$index : string
$value : string
Return values
array<string|int, mixed>

Search results