\Cake\DatasourceConnectionInterface

This interface defines the methods you can depend on in a connection.

Summary

Methods
Constants
configName()
config()
transactional()
disableConstraints()
logQueries()
logger()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

configName()

configName() : string

Get the configuration name for this connection.

Returns

string

config()

config() : array

Get the configuration data used to create the connection.

Returns

array

transactional()

transactional(callable  $transaction) : mixed

Executes a callable function inside a transaction, if any exception occurs while executing the passed callable, the transaction will be rolled back If the result of the callable function is `false`, the transaction will also be rolled back. Otherwise the transaction is committed after executing the callback.

The callback will receive the connection instance as its first argument.

Parameters

callable $transaction

The callback to execute within a transaction.

Throws

\Exception

Will re-throw any exception raised in $callback after rolling back the transaction.

Returns

mixed —

The return value of the callback.

disableConstraints()

disableConstraints(callable  $operation) : mixed

Run an operation with constraints disabled.

Constraints should be re-enabled after the callback succeeds/fails.

Parameters

callable $operation

The callback to execute within a transaction.

Throws

\Exception

Will re-throw any exception raised in $callback after rolling back the transaction.

Returns

mixed —

The return value of the callback.

logQueries()

logQueries(boolean|null  $enable = null) : boolean

Enables or disables query logging for this connection.

Parameters

boolean|null $enable

whether to turn logging on or disable it. Use null to read current value.

Returns

boolean

logger()

logger(object|null  $instance = null) : object

Sets the logger object instance. When called with no arguments it returns the currently setup logger instance.

Parameters

object|null $instance

logger object instance

Returns

object —

logger instance