CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (GitHub)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • Slack
    • Paid Support
CakePHP

C CakePHP 2.5 API

  • Overview
  • Tree
  • Deprecated
  • Version:
    • 2.5
      • 4.2
      • 4.1
      • 4.0
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Packages

  • Cake
    • Cache
      • Engine
    • Configure
    • Console
      • Command
        • Task
    • Controller
      • Component
        • Acl
        • Auth
    • Core
    • Error
    • Event
    • I18n
    • Log
      • Engine
    • Model
      • Behavior
      • Datasource
        • Database
        • Session
      • Validator
    • Network
      • Email
      • Http
    • Routing
      • Filter
      • Route
    • TestSuite
      • Coverage
      • Fixture
      • Reporter
    • Utility
    • View
      • Helper

Classes

  • AclNode
  • Aco
  • AcoAction
  • Aro
  • BehaviorCollection
  • CakeSchema
  • ConnectionManager
  • I18nModel
  • Model
  • ModelBehavior
  • ModelValidator
  • Permission

Class ConnectionManager

Manages loaded instances of DataSource objects

Provides an interface for loading and enumerating connections defined in app/Config/database.php

Package: Cake\Model
Copyright: Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
License: MIT License
Location: Cake/Model/ConnectionManager.php

Properties summary

  • $_connectionsEnum protected static
    array
    Contains a list of all file and class names used in Connection settings
  • $_dataSources protected static
    array
    Holds instances DataSource objects
  • $_init protected static
    boolean
    Indicates if the init code for this class has already been executed
  • $config public static
    DATABASE_CONFIG
    Holds a loaded instance of the Connections object

Method Summary

  • _connectionData() protected static
    Returns the file, class name, and parent for the given driver.
  • _getConnectionObject() protected static
    Gets a list of class and file names associated with the user-defined DataSource connections
  • _init() protected static
    Loads connections configuration.
  • create() public static
    Dynamically creates a DataSource object at runtime, with the given name and settings
  • drop() public static
    Removes a connection configuration at runtime given its name
  • enumConnectionObjects() public static
    Returns a list of connections
  • getDataSource() public static
    Gets a reference to a DataSource object
  • getSourceName() public static
    Gets a DataSource name from an object reference.
  • loadDataSource() public static
    Loads 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

Method Detail

_connectionData() 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

_getConnectionObject() 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

_init() protected static ¶

_init( )

Loads connections configuration.

create() 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

drop() 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

enumConnectionObjects() 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'.


getDataSource() 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

getSourceName() 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.


loadDataSource() 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

sourceList() 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 detail

$_connectionsEnum ¶

protected static array

Contains a list of all file and class names used in Connection settings

array()

$_dataSources ¶

protected static array

Holds instances DataSource objects

array()

$_init ¶

protected static boolean

Indicates if the init code for this class has already been executed

false

$config ¶

public static DATABASE_CONFIG

Holds a loaded instance of the Connections object

null
OpenHub
Rackspace
Rackspace
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (GitHub)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • Slack
  • Paid Support

Generated using CakePHP API Docs