Container for multiple DB Connections and allows switching.
Singleton Class stores the database connection information and creates db objects
when they are first accessed via DBSelector::useDB() . This also
allows them to be swapped as the active connection by scripts.
Also unsets connections if required. WARNING: see unsetDB().
| package | dstruct_common |
|---|
addConnectionString(string $connstring) : boolean
getConnection(string $key) : boolean | \multitype:
If the connection has not already been made, it connects to the DB. Also sets the connection as the current connection.
string
boolean\multitype:
getCurrent() : string
This does NOT have to be an active connection... the default (1st listed) connection is set as current when the variables are set.
stringgetInstance() : object
objectDBSelectorisConnected(string $key) : boolean
If no $key is not specified, the method will return the state of the current connection.
stringKey ref for the connection
booleanretrieveDB(string $key) : mixed
stringKey ref for the connection
mixedConnection Object, array or FalsesetCurrent(string $key) : boolean
stringKey ref for the connection
booleanReturns False if the key can not be foundswitchBackDB()
Will only work if used in conjunction with DBSelector::switchToDB().
| see | \DBSelector::switchToDB() |
|---|
switchToDB(\unknown $switchtokey)
This can be used to switch to a connection while remembering the current. You can then call DBSelector::switchBackDB() to go back to the old connection.
| see | \DBSelector::switchBackDB() |
|---|
\unknown
unsetDB(string $key) : boolean
stringKey ref for the connection
booleanTrue on success, False on failure (connection doesn't exist in object)__construct()
$current : object
$instance : object
$props : array