Jet\Db
Main façade of direct database connection system. The main purpose of the class is to hold a list of specific connections to the database, and possibly create new connections ad hoc.
Method Overview
Method | Meaning of |
---|---|
public static get( ?string $connection_name = null ):Db_Backend_Interface |
Returns an instance of the specified database connection that can already be used to perform the necessary operations. Parameters:
|
public static getConfig( ): Db_Config |
Returns the definition of the main Db configuration. That is, not the configuration of one particular connection, but the entire definition including all defined connections, specifying the default connection (and any other parameters, if defined). |
public static setConfig( Db_Config $config ): void |
Sets the entire Db configuration definition. So for example all defined connections, selection of default connection and so on. |
public static createConnection( string $connection_name, array $connection_config_data ): Db_Backend_Interface |
Ad hoc creates the database connection definition not according to the application configuration, but according to the parameters defined in a conventional way - by the associated field. The connection to the database is initialized and the connection instance is returned - thus the required operations can be performed directly. This method is useful, for example, for a single-purpose script where you need to temporarily connect to a third-party database, for example, and for various reasons it may not be entirely appropriate to put the connection definition into the application configuration. |