Propel 2 API
Class

Propel\Runtime\Propel

class Propel

Propel's main resource pool and initialization & configuration class.

This static class is used to handle Propel initialization and to maintain all of the
open database connections and instantiated database maps.

Constants

VERSION

The Propel version.

DEFAULT_NAME

A constant for <code>default</code>.

LOG_EMERG

A constant defining 'System is unusable' logging level

LOG_ALERT

A constant defining 'Immediate action required' logging level

LOG_CRIT

A constant defining 'Critical conditions' logging level

LOG_ERR

A constant defining 'Error conditions' logging level

LOG_WARNING

A constant defining 'Warning conditions' logging level

LOG_NOTICE

A constant defining 'Normal but significant' logging level

LOG_INFO

A constant defining 'Informational' logging level

LOG_DEBUG

A constant defining 'Debug-level messages' logging level

Methods

static  init(string $configFile)

Configure Propel using the given config file.

static ServiceContainerInterface getServiceContainer()

Get the service container instance.

static  setServiceContainer(ServiceContainerInterface $serviceContainer)

Set the service container instance.

static string getDefaultDatasource()

static AdapterInterface getAdapter(string $name = null)

Get the adapter for a given datasource.

static DatabaseMap getDatabaseMap(string $name = null)

Get the database map for a given datasource.

static ConnectionManagerInterface getConnectionManager(string $name)

static  closeConnections()

Close any associated resource handles.

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

Get a connection for a given datasource.

static ConnectionInterface getWriteConnection(string $name)

Get a write connection for a given datasource.

static ConnectionInterface getReadConnection(string $name)

Get a read connection for a given datasource.

static Profiler getProfiler()

Get a profiler instance.

static LoggerInterface getLogger()

Get the configured logger.

static boolean log(string $message, int $level = self::LOG_DEBUG)

Logs a message If a logger has been configured, the logger will be used, otherwise the logging message will be discarded without any further action

static boolean disableInstancePooling()

Disable instance pooling.

static boolean enableInstancePooling()

Enable instance pooling (enabled by default).

static boolean isInstancePoolingEnabled()

the instance pooling behaviour.

Details

at line 102
static public init(string $configFile)

Configure Propel using the given config file.

Parameters

string $configFile Path (absolute or relative to include_path) to config file.

at line 115
static public ServiceContainerInterface getServiceContainer()

Get the service container instance.

at line 129
static public setServiceContainer(ServiceContainerInterface $serviceContainer)

Set the service container instance.

Parameters

ServiceContainerInterface $serviceContainer

at line 137
static public string getDefaultDatasource()

Return Value

string

at line 151
static 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 165
static 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 175
static public ConnectionManagerInterface getConnectionManager(string $name)

Parameters

string $name The datasource name

Return Value

ConnectionManagerInterface

at line 186
static public closeConnections()

Close any associated resource handles.

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

at line 202
static public ConnectionInterface getConnection(string $name = null, string $mode = ServiceContainerInterface::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 220
static 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

PropelException - if connection is not properly configured

at line 237
static 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 247
static public Profiler getProfiler()

Get a profiler instance.

Return Value

Profiler

at line 257
static public LoggerInterface getLogger()

Get the configured logger.

Return Value

LoggerInterface Configured log class

at line 272
static public boolean log(string $message, int $level = self::LOG_DEBUG)

Logs a message If a logger has been configured, the logger will be used, otherwise the logging message will be discarded without any further action

Parameters

string $message The message that will be logged.
int $level The logging level.

Return Value

boolean True if the message was logged successfully or no logger was used.

at line 302
static public boolean disableInstancePooling()

Disable instance pooling.

Return Value

boolean true if the method changed the instance pooling state, false if it was already disabled

at line 318
static public boolean enableInstancePooling()

Enable instance pooling (enabled by default).

Return Value

boolean true if the method changed the instance pooling state, false if it was already enabled

at line 333
static public boolean isInstancePoolingEnabled()

the instance pooling behaviour.

True by default.

Return Value

boolean Whether the pooling is enabled or not.