ezcDbFactory manages the list of known database drivers and is used to create their instances.
Example:
Instead of passing an array with those parameters, you can also pass a DSN:
Other examples of DSNs are:
Note that this class does not deal with character sets automatically, you have to make sure that you do that yourself. For MySQL that means running a query "SET NAMES" for example. See the tutorial for some hints on this.
Source for this file: /Database/src/factory.php
Version: | //autogentag// |
public static void |
addImplementation(
$implementationName
, $className
)
Adds a database implementation to the list of known implementations. |
public static ezcDbHandler |
create(
$dbParams
)
Creates and returns an instance of the specified ezcDbHandler implementation. |
public static array(string) |
getImplementations(
)
Returns a list with supported database implementations. |
public static array |
parseDSN(
$dsn
)
Returns the Data Source Name as a structure containing the various parts of the DSN. |
Adds a database implementation to the list of known implementations.
$implementationName is the name of the implemenation. This name should be short and uniquely identify the database. $className is the class name of the class that implements the handler for this database.
Example:
Name | Type | Description |
---|---|---|
$implementationName |
string | |
$className |
string |
Creates and returns an instance of the specified ezcDbHandler implementation.
Supported database parameters are:
Name | Type | Description |
---|---|---|
$dbParams |
mixed | Database parameters (driver, host, port, user, pass, etc). May be specified either as array (key => val ....) or as DSN string. Format of the DSN is the same as accepted by PEAR::DB::parseDSN(). |
Type | Description |
---|---|
ezcDbHandlerNotFoundException |
if the requested database handler could not be found. |
Returns a list with supported database implementations.
Example:
Returns the Data Source Name as a structure containing the various parts of the DSN.
Additional keys can be added by appending a URI query string to the end of the DSN.
The format of the supplied DSN is in its fullest form:
Most variations are allowed:
This function is 'borrowed' from PEAR /DB.php .
Name | Type | Description |
---|---|---|
$dsn |
string | Data Source Name to be parsed |