IConnectionManager
in
Interface for managing database connections pool.
Table of Contents
Methods
- Connect() : mixed
- Establishes a new database connection.
- Disconnect() : void
- Closes a specific database connection.
- DisconnectAll() : void
- Closes all open database connections.
- GetConnection() : mixed
- Retrieves a database connection handle.
- GetConnectionError() : int
- Gets the last error number for a connection.
- GetConnectionErrorString() : string
- Gets the last error string for a connection.
- GetDbmsType() : string
- Get the name of DBMS used
- GetDefaultKey() : string|null
- Gets the current default connection key.
- HasConnection() : bool
- Checks if a connection exists and is active.
- RealConnection() : bool
- Performs the actual connection based on the current parameters.
- SetAutoCommit() : void
- Sets autocommit mode for connections.
- SetDefaultKey() : void
- Sets the default connection key.
Methods
Connect()
Establishes a new database connection.
public
Connect(string $dbname, string $username, string $pwd, string $hostname, int|string $port) : mixed
Parameters
- $dbname : string
-
Database name
- $username : string
-
Database username
- $pwd : string
-
Database password
- $hostname : string
-
Database host
- $port : int|string
-
Database port
Tags
Return values
mixed —The connection handle
Disconnect()
Closes a specific database connection.
public
Disconnect([string|null $connectionKey = null ]) : void
Parameters
- $connectionKey : string|null = null
-
Connection identifier key, null for default
DisconnectAll()
Closes all open database connections.
public
DisconnectAll() : void
GetConnection()
Retrieves a database connection handle.
public
GetConnection([string|null $connectionKey = null ]) : mixed
Parameters
- $connectionKey : string|null = null
-
Connection identifier key, null for default
Return values
mixed —The connection handle or null if not connected
GetConnectionError()
Gets the last error number for a connection.
public
GetConnectionError([string|null $connectionKey = null ]) : int
Parameters
- $connectionKey : string|null = null
-
Connection identifier key, null for default
Return values
int —Error number, 0 if no error
GetConnectionErrorString()
Gets the last error string for a connection.
public
GetConnectionErrorString([string|null $connectionKey = null ]) : string
Parameters
- $connectionKey : string|null = null
-
Connection identifier key, null for default
Return values
string —Error message
GetDbmsType()
Get the name of DBMS used
public
GetDbmsType() : string
Return values
string —the name of DBMS used. i.e.: mysql, oracle, postgresql (the convention is all in lowercase)
GetDefaultKey()
Gets the current default connection key.
public
GetDefaultKey() : string|null
Return values
string|null —The default connection key or null
HasConnection()
Checks if a connection exists and is active.
public
HasConnection([string|null $connectionKey = null ]) : bool
Parameters
- $connectionKey : string|null = null
-
Connection identifier key, null for default
Return values
bool —True if connected, false otherwise
RealConnection()
Performs the actual connection based on the current parameters.
public
RealConnection() : bool
Tags
Return values
bool —True if connection successful
SetAutoCommit()
Sets autocommit mode for connections.
public
SetAutoCommit(bool $autocommit) : void
Parameters
- $autocommit : bool
-
True for autocommit, false for manual commit
SetDefaultKey()
Sets the default connection key.
public
SetDefaultKey(string $connectionKey) : void
Parameters
- $connectionKey : string
-
The connection key to set as default