|
Stud.IP
2.4 Revision 48548
|

Public Member Functions | |
| getConnection ($database) | |
| setConnection ($database, $dsnOrConnection, $user=NULL, $pass=NULL) | |
| aliasConnection ($old, $new) | |
Static Public Member Functions | |
| static | getInstance () |
| static | get ($database= 'studip') |
This class provides a singleton instance that is used to manage PDO database connections.
Example of use:
| aliasConnection | ( | $old, | |
| $new | |||
| ) |
This method creates an alias for a database connection.
This is useful if you want to use different keys but access the same database, e.g. if you want to use master-slave replication in the future
| string | the old key of the database connection |
| string | the new key of the database connection |
|
static |
Shortcut static method to retrieve the database connection for a given key.
Example usage:
| string | the key |

| getConnection | ( | $database | ) |
This method returns the database connection to the given key. Throws a DBManagerException if there is no such connection.
Example usage:
| string | the key |
| DBManagerException |
|
static |
This method returns the singleton instance of this class.

| setConnection | ( | $database, | |
| $dsnOrConnection, | |||
$user = NULL, |
|||
$pass = NULL |
|||
| ) |
This method maps the specified key to the specified database connection.
You can either use an instance of class PDO or specify a DSN (optionally with username/password).
The (possibly newly created) connection is configured to throw exceptions and to buffer queries if it is a MySQL connection.
Examples:
| string | the key |
| string|PDO | either a DSN or an existing PDO connection |
| string | (optional) the connection's username |
| array | (optional) the connection's password |