Manages loaded instances of DataSource objects
Provides an interface for loading and enumerating connections defined in app/Config/database.php
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
arrayContains a list of all file and class names used in Connection settings
arrayHolds instances DataSource objects
booleanIndicates if the init code for this class has already been executed
DATABASE_CONFIGHolds a loaded instance of the Connections object
_connectionData() protected staticReturns the file, class name, and parent for the given driver.
_getConnectionObject() protected staticGets a list of class and file names associated with the user-defined DataSource connections
_init() protected staticLoads connections configuration.
create() public staticDynamically creates a DataSource object at runtime, with the given name and settings
drop() public staticRemoves a connection configuration at runtime given its name
enumConnectionObjects() public staticReturns a list of connections
getDataSource() public staticGets a reference to a DataSource object
getSourceName() public staticGets a DataSource name from an object reference.
loadDataSource() public staticLoads the DataSource class for the given connection name
sourceList() public static
Gets the list of available DataSource connections This will only return the datasources instantiated by this manager It differs from enumConnectionObjects, since the latter will return all configured connections
_connectionData() protected static ¶
_connectionData( array $config )
Returns the file, class name, and parent for the given driver.
- array $config
- Array with connection configuration. Key 'datasource' is required
An indexed array with: filename, classname, plugin and parent
_getConnectionObject() protected static ¶
_getConnectionObject( string $name )
Gets a list of class and file names associated with the user-defined DataSource connections
- string $name
- Connection name
create( string $name = '' , array $config = array() )
Dynamically creates a DataSource object at runtime, with the given name and settings
- string $name optional ''
- The DataSource name
- array $config optional array()
- The DataSource configuration settings
A reference to the DataSource object, or null if creation failed
drop( string $name )
Removes a connection configuration at runtime given its name
- string $name
- the connection name as it was created
success if connection was removed, false if it does not exist
enumConnectionObjects() public static ¶
Returns a list of connections
An associative array of elements where the key is the connection name (as defined in Connections), and the value is an array with keys 'filename' and 'classname'.
getDataSource() public static ¶
getDataSource( string $name )
getSourceName() public static ¶
DataSource $source )
Gets a DataSource name from an object reference.
- DataSource object
Datasource name, or null if source is not present in the ConnectionManager.
loadDataSource() public static ¶
loadDataSource( string|array $connName )
Loads the DataSource class for the given connection name
- string|array $connName
A string name of the connection, as defined in app/Config/database.php, or an array containing the filename (without extension) and class name of the object, to be found in app/Model/Datasource/ or lib/Cake/Model/Datasource/.
True on success, null on failure or false if the class is already loaded
Contains a list of all file and class names used in Connection settings
Indicates if the init code for this class has already been executed