PHP Class DBConnection, glpi

Author: sabuj.das
Show file Open project: glpi-project/glpi Class Usage Examples

Protected Properties

Property Type Description
$notable

Public Methods

Method Description
changeCronTaskStatus ( $enable = true ) Enable or disable db replication check cron task
createDBSlaveConfig ( ) Create a default slave DB configuration file
createMainConfig ( $host, $user, $password, $DBname ) : boolean Create GLPI main configuration file
createSlaveConnectionFile ( $host, $user, $password, $DBname ) : boolean Create slave DB configuration file
cronCheckDBreplicate ( $task ) Cron process to check DB replicate state
cronInfo ( $name )
deleteDBSlaveConfig ( ) Delete slave DB configuration file
displayMySQLError ( ) Display a common mysql connection error
establishDBConnection ( $use_slave, $required, $display = true ) Establish a connection to a mysql server (main or replicate)
getDBSlaveConf ( $choice = NULL ) : DBmysql Read slave DB configuration file
getHistoryMaxDate ( $DBconnection ) Get history max date of a GLPI DB
getReadConnection ( ) : DBmysql Get Connection to slave, if exists, and if configured to be used for read only request
getReplicateDelay ( $choice = NULL ) : integer Get delay between slave and master
getTypeName ( $nb )
isDBSlaveActive ( ) : true Indicates is the DB replicate is active or not
saveDBSlaveConf ( $host, $user, $password, $DBname ) Save changes to the slave DB configuration file
showAllReplicateDelay ( ) Display in HTML, delay between master and slave 1 line per slave is multiple
showSystemInformations ( $width )
switchToMaster ( ) Switch database connection to master
switchToSlave ( ) Switch database connection to slave

Method Details

changeCronTaskStatus() static public method

Enable or disable db replication check cron task
static public changeCronTaskStatus ( $enable = true )

createDBSlaveConfig() static public method

Create a default slave DB configuration file
static public createDBSlaveConfig ( )

createMainConfig() static public method

Create GLPI main configuration file
Since: 9.1
static public createMainConfig ( $host, $user, $password, $DBname ) : boolean
$user
$password
$DBname
return boolean

createSlaveConnectionFile() static public method

Create slave DB configuration file
static public createSlaveConnectionFile ( $host, $user, $password, $DBname ) : boolean
return boolean for success

cronCheckDBreplicate() static public method

Cron process to check DB replicate state
static public cronCheckDBreplicate ( $task )
$task to log and get param

cronInfo() static public method

static public cronInfo ( $name )
$name

deleteDBSlaveConfig() static public method

Delete slave DB configuration file
static public deleteDBSlaveConfig ( )

displayMySQLError() static public method

Display a common mysql connection error
static public displayMySQLError ( )

establishDBConnection() static public method

Establish a connection to a mysql server (main or replicate)
static public establishDBConnection ( $use_slave, $required, $display = true )
$use_slave try to connect to slave server first not to main server
$required connection to the specified server is required (if connection failed, do not try to connect to the other server)
$display display error message (true by default)

getDBSlaveConf() static public method

Read slave DB configuration file
static public getDBSlaveConf ( $choice = NULL ) : DBmysql
$choice integer, host number (default NULL)
return DBmysql object

getHistoryMaxDate() static public method

Get history max date of a GLPI DB
static public getHistoryMaxDate ( $DBconnection )
$DBconnection DB conneciton used

getReadConnection() static public method

Get Connection to slave, if exists, and if configured to be used for read only request
static public getReadConnection ( ) : DBmysql
return DBmysql object

getReplicateDelay() static public method

Get delay between slave and master
static public getReplicateDelay ( $choice = NULL ) : integer
$choice integer, host number (default NULL)
return integer

getTypeName() static public method

static public getTypeName ( $nb )

isDBSlaveActive() static public method

Indicates is the DB replicate is active or not
static public isDBSlaveActive ( ) : true
return true if active / false if not active

saveDBSlaveConf() static public method

Save changes to the slave DB configuration file
static public saveDBSlaveConf ( $host, $user, $password, $DBname )
$host
$user
$password
$DBname

showAllReplicateDelay() static public method

Display in HTML, delay between master and slave 1 line per slave is multiple
static public showAllReplicateDelay ( )

showSystemInformations() public method

public showSystemInformations ( $width )
$width

switchToMaster() static public method

Switch database connection to master
static public switchToMaster ( )

switchToSlave() static public method

Switch database connection to slave
static public switchToSlave ( )

Property Details

$notable protected static property

protected static $notable