DatabaseHelpers
in package
Trait for installer/configurator classes.
Tags
Table of Contents
- $dbProfile : string
- $globalSetup : GlobalSetup
- global setup.
- $_dbConn : jDbConnection
- __construct() : mixed
- createTableFromDao() : mixed
- dbConnection() : jDbConnection
- dbTool() : jDbTools
- execSQLScript() : mixed
- execute a sql script with the current profile.
- getDbProfile() : mixed
- getDbType() : string
- insertDaoData() : int
- Insert data into a database, from a json file, using a DAO mapping.
- useDbProfile() : mixed
- use the given database profile. check if this is an alias and use the real db profile if this is the case.
Properties
$dbProfile
protected
string
$dbProfile
= ''
the jDb profile for the component
Tags
$globalSetup
global setup.
protected
GlobalSetup
$globalSetup
Tags
$_dbConn
private
jDbConnection
$_dbConn
Tags
Methods
__construct()
public
__construct(GlobalSetup $setup) : mixed
Parameters
- $setup : GlobalSetup
Tags
Return values
mixed —createTableFromDao()
public
createTableFromDao( $selectorStr) : mixed
Parameters
Tags
Return values
mixed —dbConnection()
public
dbConnection() : jDbConnection
Tags
Return values
jDbConnection —the connection to the database used for the module
dbTool()
public
dbTool() : jDbTools
Tags
Return values
jDbTools —the tool class of jDb
execSQLScript()
execute a sql script with the current profile.
public
execSQLScript(string $name[, string $module = null ][, bool $inTransaction = true ]) : mixed
The name of the script should be store in install/$name.databasetype.sql in the directory of the component. (replace databasetype by mysql, pgsql etc.) You can however provide a script compatible with all databases, but then you should indicate the full name of the script, with a .sql extension.
Parameters
- $name : string
-
the name of the script
- $module : string = null
-
the module from which we should take the sql file. null for the current module
- $inTransaction : bool = true
-
indicate if queries should be executed inside a transaction
Tags
Return values
mixed —getDbProfile()
public
getDbProfile() : mixed
Tags
Return values
mixed —getDbType()
public
getDbType([string $profile = null ]) : string
Parameters
- $profile : string = null
-
the db profile
Tags
Return values
string —the name of the type of database
insertDaoData()
Insert data into a database, from a json file, using a DAO mapping.
public
insertDaoData(string $relativeSourcePath, int $option[, null|mixed $module = null ]) : int
Parameters
- $relativeSourcePath : string
-
name of the json file into the install directory
- $option : int
-
one of jDbTools::IBD_* const
- $module : null|mixed = null
Tags
Return values
int —number of records inserted/updated
useDbProfile()
use the given database profile. check if this is an alias and use the real db profile if this is the case.
public
useDbProfile(string $dbProfile) : mixed
Parameters
- $dbProfile : string
-
the profile name