ePages 6.11.0 - DE_EPAGES/ShopTransfer/API/DBI.pm

Package DE_EPAGES::ShopTransfer::API::DBI

Functions

GetIDByPath
IsColumnObjectID
disableForeignKeyChecks
dynamicIDTables
existsColumn
exportableTables
getAliasByID
getAllColumns
getAllPrimaryKeys
getAllReferences
getColumnPosition
getColumns
getDBName
getGeneralizeDateTimeStatement
getMasterColumn
getMasterOfReference
getObjectColumn
getPKeyOfTable
getReferenceColumns
getTableReferences
getTables
getTypesOfColumns
getUniqueIndexes
isColumnAutoIncrement
quoteParameter
shopTables
systemTables

GetIDByPath

Returns the identifier of an object without loading objects.

Syntax
$ObjectID = $dbi->getIDByPath(@Path);
Example
$ShopID = $dbi->getIDByPath('Shops',$ShopAlias);
Input
@Path (array.string)
path names
Return
$ObjectID (integer)
indentifier

IsColumnObjectID

Returns true the columns is a object identifier.

Syntax
$IsObjectColumn = $dbi->isColumnObjectID($Table, $Column);
Input
$Table (string)
table name
$Column (string)
column name
Return
$IsObjectColumn (boolean)
column an object identifier

disableForeignKeyChecks

Disables foreign key checks during execution of $Code.

Syntax
$dbi->disableForeignKeyChecks($Code);
Input
$Code (code)
code reference

dynamicIDTables

Returns exportable tables, which have only one primary key, no foreign key on it and no autoincrement.

Syntax
$aTables = $dbi->dynamicIDTables();
Return
$aTables (ref.array.string)
list of table names

existsColumn

Returns true if column exists in table.

Syntax
$Exists = $dbi->existsColumn($Table, $Column)
Input
$Table (string)
table name
$Column (string)
column name
Return
$Exists (boolean)
true if column exists

exportableTables

Returns list of tables names to consider for export, in correct order of delete. Exceptions are: IGNORE_TABLES_EXPORT and those ending in '_nextid'.

Syntax
$aTables = $dbi->exportableTables();
Return
$aTables (ref.array.string)
table names

getAliasByID

Returns the alias of an object without loading objects. Returns undef if the object does not exist.

Syntax
$Alias = $dbi->getAliasByID( $ObjectID );
Input
$ObjectID (integer)
indentifier
Return
$Alias (string)
alias

getAllColumns

Returns all columns of all tables in the current database.

Syntax
$hTableColumns = $dbi->getAllColumns;
Return
$hTableReferences (ref.hash.hash.hash.string)

{
$TableName => {
$ColumnName => {
Position => $Position,
},...
}, ...
}

getAllPrimaryKeys

Returns all primary keys of all tables in the current database.

Syntax
$hTablePrimaryKeys = $dbi->getAllPrimaryKeys;
Input
$Table (string)
table name
Return
$hTableReferences (ref.hash.hash.string/array)

{
$TableName => [ $ColumnName, ... ],
...
}

getAllReferences

Returns all foreign keys of all tables in the current database.

Syntax
$hTableReferences = $dbi->getAllReferences;
Return
$hTableReferences (ref.hash.hash.hash.string)

{
$TableName => {
$ColumnName => {
ConstraintName => $ConstraintName,
MasterTableName => $MasterTableName,
MasterColumnName => $MasterColumnName,
},...
}, ...
}

getColumnPosition

Returns the position of the column (start with 0). Returns undef if column does not exist.

Syntax
$Position = $dbi->getColumnPosition($Table, $Column);
Input
$Table (string)
table name
$Column (string)
column name
Return
$Position (integer)
position of column

getColumns

Returns all columns.

Syntax
@Columns = $dbi->getColumns($Table);
Input
$Table (string)
table name
Return
@Columns (array.string)
column names

getDBName

returns the current db name.

Syntax
$DbName = $dbi->getDBName();
Return
$DbName (string)
name of current database

getGeneralizeDateTimeStatement

Returns a statement for querying datetime columns in a generalized format. Instead of returning the plain column name, a convert statement like 'convert(char(19), $TablePrefix$Column, 117)' is returned and can be integrated into a 'SELECT $statement from table where bla' query.

Syntax
$statement = $dbi->getGeneralizeDateTimeStatement($Column, $TablePrefix);
Input
$Column (string)
column name
$TablePrefix (string)
prefix, which should be inserted before the column name
Return
$statement (string)
the new column statement

getMasterColumn

Returns the masterMaster of a foreign key chain. Returns undef unless there is no reference.

Syntax
($MasterTable, $MasterColumn) = $dbi->getMasterColumn($Table, $Column);
Input
$Table (string)
slave table name
$Column (string)
slave column name
Return
$MasterTable (string)
masterMaster table name
$MasterColumn (string)
masterMaster column name

getMasterOfReference

Returns the master of foreign key. Returns an empty array if there is no reference.

Syntax
($MasterTable, $MasterColumn) = $dbi->getMasterOfReference($Table, $Column);
Input
$Table (string)
slave table name
$Column (string)
slave column name
$MasterTable (string)
master table name
$MasterColumn (string)
master column name

getObjectColumn

Returns the column which can be used for siteid assignment.

Syntax
$Column = $dbi->getObjectColumn($Table);
Input
$Table (string)
table name
Return
$Column (string)
column name

getPKeyOfTable

Returns the primary key of a table. Returns an empty array if the table does not have a primary key.

Syntax
@PrimaryKeyColumns = $dbi->getPKeyOfTable($Table);
$PrimaryKeyColumn = $dbi->getPKeyOfTable($Table);
Input
$Table (string)
table name
Return
@PrimaryKeyColumns (array.string)
column names
$PrimaryKeyColumn (string)
first column name

getReferenceColumns

Returns the columns of a table, which have foreign keys.

Syntax
@Columns = $dbi->getReferenceColumns($Table);
Input
$Table (string)
table name
Return
@Columns (array.string)
column names

getTableReferences

Returns the reference info of a table. Returns an empty hash if the table has no references.

Syntax
$hReferences = $dbi->getTableReferences($Table);
Input
$Table (string)
table name
Return
$hReferences (ref.hash.hash.string)

{
$ColumnName => {
ConstraintName => $ConstraintName,
MasterTableName => $MasterTableName,
MasterColumnName => $MasterColumnName,
},...
}

getTables

Returns list of all table names, in correct order of delete.

Syntax
$aTables = $dbi->getTables();
Return
$aTables (ref.array.string)
table names

getTypesOfColumns

Returns types of columns. Currently used types: bit,char,datetime,float, int,money,nchar,numeric,nvarchar,text,tinyint,varchar

Syntax
$hTypes= $dbi->getTypesOfColumns($Table);
Input
$Table (string)
table name
Return
$hTypes (ref.hash.string)
column types key: columnname value: type

getUniqueIndexes

Returns first columns of all unique indexes.

Syntax
@Columns = $dbi->getUniqueIndexes($Table);
Input
$Table (string)
table name
Return
@Columns (array.string)
column names

isColumnAutoIncrement

Returns 1 if the table has an auto increment column or an _nextid table

Syntax
$isAutoInc = $dbi->isColumnAutoIncrement($Table);
Input
$Table (string)
table name
Return
$Parameter (int)
binary value

quoteParameter

Tests and quotes the parameters according to the data type spefification.

Syntax
$Parameter = $dbi->quoteParameter($Type, $Value);
Example
$Parameter = $dbi->quoteParameter('String', "don't");
Input
$Type (ref.hash)
data type specification for parameters
$Value (*)
value
Return
$Parameter (string)
parameter for database

shopTables

Returns the tables to consider for export of shops.

Syntax
$aTables = $dbi->shopTables();
Return
$aTables (ref.array.string)
list of table names

systemTables

Returns the tables to consider for export of the system.

Syntax
$aTables = $dbi->systemTables();
Return
$aTables (ref.array.string)
list of table names