Class ConnectionManager
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
Located at Cake/Model/ConnectionManager.php
Method Detail
_connectionDatasource protected static
_connectionData( array $config )
Returns the file, class name, and parent for the given driver.
Parameters
- array
$config
- Array with connection configuration. Key 'datasource' is required
Returns
array
An indexed array with: filename, classname, plugin and parent
_getConnectionObjectsource protected static
_getConnectionObject( string $name )
Gets a list of class and file names associated with the user-defined DataSource connections
Parameters
- string
$name
- Connection name
Throws
MissingDatasourceConfigException
MissingDatasourceConfigException
createsource public static
create( string $name '' , array $config array() )
Dynamically creates a DataSource object at runtime, with the given name and settings
Parameters
- string
$name
optional '' - The DataSource name
- array
$config
optional array() - The DataSource configuration settings
Returns
DataSource|null
A reference to the DataSource object, or null if creation failed
dropsource public static
drop( string $name )
Removes a connection configuration at runtime given its name
Parameters
- string
$name
- the connection name as it was created
Returns
boolean
success if connection was removed, false if it does not exist
enumConnectionObjectssource public static
enumConnectionObjects( )
Returns a list of connections
Returns
array
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'.
getDataSourcesource public static
getDataSource( string $name )
Gets a reference to a DataSource object
Parameters
- string
$name
- The name of the DataSource, as defined in app/Config/database.php
Returns
DataSource
Instance
Throws
MissingDatasourceException
MissingDatasourceException
getSourceNamesource public static
getSourceName( DataSource $source )
Gets a DataSource name from an object reference.
Parameters
-
DataSource
$source
- DataSource object
Returns
string|null
Datasource name, or null if source is not present in the ConnectionManager.
loadDataSourcesource public static
loadDataSource( string|array $connName )
Loads the DataSource class for the given connection name
Parameters
- 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/.
Returns
boolean
True on success, null on failure or false if the class is already loaded
Throws
MissingDatasourceException
MissingDatasourceException
sourceListsource public static
sourceList( )
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
Returns
array
List of available connections
Properties summary
© 2005–2016 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
http://api.cakephp.org/2.7/class-ConnectionManager.html