ePages 6.17.9 - DE_EPAGES/ShopTransfer/API/DBImySQL.pm

Package DE_EPAGES::ShopTransfer::API::DBImySQL

MySQL specific database access functions.

Functions

autoIncrementNextID
disableForeignKeyChecks
getAllColumns
getAllPrimaryKeys
getAllReferences
getGeneralizeDateTimeStatement
getTypesOfColumns
getUniqueIndexes
isColumnAutoIncrement
isNullable
reserveIdentifier

autoIncrementNextID

Returns the AUTO_INCREMENT value of the given table, i.e. the id of the next row to be inserted.

Syntax
$AutoIncrement = $dbi->autoIncrementNextID($Table);
Input
$Table (string)
table name
Return
$AutoIncrement (integer)
AUTO_INCREMENT value

disableForeignKeyChecks

Disables foreign key checks during execution of $Code.

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

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
$hPrimaryKeys = $dbi->getAllPrimaryKeys;
Return
$hPrimaryKeys (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,
},...
}, ...
}

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);
Input
$Column (string)
column name
$TablePrefix (string)
prefix, which should be inserted before the column name
Return
$statement (string)
the new column statement

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();
Input
$Table (string)
table name
Return
$Parameter (int)
binary value

isNullable

Returns true if the table column is nullable. Returns false if the column is not nullable or if it does not exist.

Syntax
$IsNullable = $dbi->isNullable($Table, $Column);
Input
$Table (string)
table name
$Column (string)
column name
Return
$IsNullable (boolean)
true if the column is nullable

reserveIdentifier

Increments the AUTO_INCREMENT by $CountOfRows to reserve a block of ids.

Syntax
$FirstNextID = $dbi->reserveIdentifier($Table, $CountOfRows);
Input
$Table (string)
table name
$CountOfRows (integer)
requested row count
Return
$FirstNextID (integer)
first free identifier