CSDatabaseUtils
in package
This utility class offers utility methods for database communication
Tags
Table of Contents
- commit() : mixed
- Commits the current database transaction which has been started using the startTransaction method before
- createProcedure() : bool
- Creates a specific stored procedure in DB.
- createProcedures() : void
- This method creates stored procedures in DB. Folders searched for these procedures are - admin/classes/database/[DBType]/procedures - admin.local/core/utils/database/[DBType]/procedures - [PROJECT]/core/utils/database/[DBType]/procedures
- createSQLHelperFunction() : bool
- Creates a specific function.
- createSQLHelperFunctions() : void
- This method creates stored procedures for a certain recordtype. Folders searched for these procedures are - admin/classes/database/[DBType]/functions - admin.local/core/utils/database/[DBType]/functions - [PROJECT]/core/utils/database/[DBType]/functions
- getProcedureNameFromString() : string
- Extracts the procedure/function name from a given SQL string
- rollback() : mixed
- Rolls back the current database transaction which has been started using the startTransaction method before
- startTransaction() : mixed
- Starts a database transaction The transaction must be ended by calling the rollback or commit method
Methods
commit()
Commits the current database transaction which has been started using the startTransaction method before
public
static commit() : mixed
Tags
Return values
mixed —createProcedure()
Creates a specific stored procedure in DB.
public
createProcedure(string $sProcedureFilePath[, array<string|int, mixed> $aTokenReplacements = array() ]) : bool
Procedure name must contain the db prefix token ({dbPrefix}) in order to be created. Within the procedure all calls to custom procedures/functions must as well be flagged with the token in order to work correctly in multi install environments. If not all tokens can be replaced, the procedure will not be created. The file type must be "sql".
Parameters
- $sProcedureFilePath : string
-
The path to the sql containing the stored procedure
- $aTokenReplacements : array<string|int, mixed> = array()
-
An associative array having the tokens to be replaced as key and the replacement as value
Tags
Return values
bool —TRUE if procedure was created or FALSE if not all tokens are replaced
createProcedures()
This method creates stored procedures in DB. Folders searched for these procedures are - admin/classes/database/[DBType]/procedures - admin.local/core/utils/database/[DBType]/procedures - [PROJECT]/core/utils/database/[DBType]/procedures
public
static createProcedures(array<string|int, mixed> $aTokenReplacements[, array<string|int, mixed> $aFileNames = array() ][, string $sDBType = 'sql' ]) : void
Stored procedure files need special preparations: @see CSDatabaseUtils::createProcedure()
WARNING: This will only create those procedures where all tokens are replaced successfully
Parameters
- $aTokenReplacements : array<string|int, mixed>
-
An associative array having the tokens to be replaced as key and the replacement as value
- $aFileNames : array<string|int, mixed> = array()
-
An array containing the the specific sql file names for which the procedures are to be created. If specified, only these will be created.
- $sDBType : string = 'sql'
-
The database type the SP was created for. needed to find the correct folder in file system
Tags
Return values
void —createSQLHelperFunction()
Creates a specific function.
public
static createSQLHelperFunction(string $sFilePath, array<string|int, mixed> $aTokensReplacements) : bool
Function name must contain the db prefix token ({dbPrefix}) in order to be created. Within the function all calls to custom procedures/functions must as well be flagged with the token in order to work correctly in multi install environments. If not all tokens can be replaced, the procedure will not be created. The file type must be "sql".
Parameters
- $sFilePath : string
-
The path to the sql containing the function
- $aTokensReplacements : array<string|int, mixed>
-
An associative array having the tokens to be replaced as key and the replacement as value
Tags
Return values
bool —TRUE if function was created or FALSE if not all tokens are replaced
createSQLHelperFunctions()
This method creates stored procedures for a certain recordtype. Folders searched for these procedures are - admin/classes/database/[DBType]/functions - admin.local/core/utils/database/[DBType]/functions - [PROJECT]/core/utils/database/[DBType]/functions
public
static createSQLHelperFunctions([array<string|int, mixed> $aTokensReplacements = array() ][, string $sDBType = 'sql' ]) : void
Function files need special preparations: @see CSDatabaseUtils::createSQLHelperFunction()
WARNING: This will only create those procedures where all tokens are replaced successfully
Parameters
- $aTokensReplacements : array<string|int, mixed> = array()
-
An associative array having the tokens to be replaced as key and the replacement as value
- $sDBType : string = 'sql'
-
The database type the SP was created for. needed to find the correct folder in file system
Tags
Return values
void —getProcedureNameFromString()
Extracts the procedure/function name from a given SQL string
public
static getProcedureNameFromString(string $sSql) : string
Parameters
- $sSql : string
-
The sql of the procedure
Tags
Return values
string —The procedure/function name
rollback()
Rolls back the current database transaction which has been started using the startTransaction method before
public
static rollback() : mixed
Tags
Return values
mixed —startTransaction()
Starts a database transaction The transaction must be ended by calling the rollback or commit method
public
static startTransaction() : mixed
