Propel 2 API
Interface

Propel\Runtime\ServiceContainer\ServiceContainerInterface

interface ServiceContainerInterface

Constants

CONNECTION_READ

Constant used to request a READ connection (applies to replication).

CONNECTION_WRITE

Constant used to request a WRITE connection (applies to replication).

DEFAULT_DATABASE_MAP_CLASS

The default DatabaseMap class created by getDatabaseMap()

DEFAULT_DATASOURCE_NAME

The name of the default datasource.

DEFAULT_PROFILER_CLASS

The name of the default Profiler class created by getProfiler()

Methods

string getDefaultDatasource()

AdapterInterface getAdapter(string $name = null)

Get the adapter for a given datasource.

DatabaseMap getDatabaseMap(string $name = null)

Get the database map for a given datasource.

ConnectionManagerInterface getConnectionManager(string $name)

closeConnections()

Close any associated resource handles.

ConnectionInterface getConnection(string $name = null, string $mode = self::CONNECTION_WRITE)

Get a connection for a given datasource.

ConnectionInterface getWriteConnection(string $name)

Get a write connection for a given datasource.

ConnectionInterface getReadConnection(string $name)

Get a read connection for a given datasource.

Profiler getProfiler()

Get a profiler instance.

LoggerInterface getLogger($name = 'defaultLogger')

Get a logger for a given datasource, or the default logger.

Details

at line 46
public string getDefaultDatasource()

Return Value

string

at line 57
public AdapterInterface getAdapter(string $name = null)

Get the adapter for a given datasource.

If the adapter does not yet exist, build it using the related adapterClass.

Parameters

string $name The datasource name

Return Value

AdapterInterface

at line 68
public DatabaseMap getDatabaseMap(string $name = null)

Get the database map for a given datasource.

The database maps are "registered" by the generated map builder classes.

Parameters

string $name The datasource name

Return Value

DatabaseMap

at line 75
public ConnectionManagerInterface getConnectionManager(string $name)

Parameters

string $name The datasource name

Return Value

ConnectionManagerInterface

at line 83
public closeConnections()

Close any associated resource handles.

This method frees any database connection handles that have been
opened by the getConnection() method.

at line 96
public ConnectionInterface getConnection(string $name = null, string $mode = self::CONNECTION_WRITE)

Get a connection for a given datasource.

If the connection has not been opened, open it using the related
connectionSettings. If the connection has already been opened, return it.

Parameters

string $name The datasource name
string $mode The connection mode (this applies to replication systems).

Return Value

ConnectionInterface A database connection

at line 111
public ConnectionInterface getWriteConnection(string $name)

Get a write connection for a given datasource.

If the connection has not been opened, open it using the related
connectionSettings. If the connection has already been opened, return it.

Parameters

string $name The datasource name that is used to look up the DSN from the runtime configuration file. Empty name not allowed.

Return Value

ConnectionInterface A database connection

Exceptions

AdapterException - if connection is not properly configured

at line 125
public ConnectionInterface getReadConnection(string $name)

Get a read connection for a given datasource.

If the slave connection has not been opened, open it using a random read connection
setting for the related datasource. If no read connection setting exist, return the master
connection. If the slave connection has already been opened, return it.

Parameters

string $name The datasource name that is used to look up the DSN from the runtime configuration file. Empty name not allowed.

Return Value

ConnectionInterface A database connection

at line 132
public Profiler getProfiler()

Get a profiler instance.

Return Value

Profiler

at line 139
public LoggerInterface getLogger($name = 'defaultLogger')

Get a logger for a given datasource, or the default logger.

Parameters

$name

Return Value

LoggerInterface