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.
string
getInstance() : object
object
DBSelectorisConnected(string $key) : boolean
If no $key is not specified, the method will return the state of the current connection.
string
Key ref for the connection
boolean
retrieveDB(string $key) : mixed
string
Key ref for the connection
mixed
Connection Object, array or FalsesetCurrent(string $key) : boolean
string
Key ref for the connection
boolean
Returns 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
string
Key ref for the connection
boolean
True on success, False on failure (connection doesn't exist in object)__construct()
$current : object
$instance : object
$props : array