Interface ConnectionInterface

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

Direct known implementers

Cake\Database\Connection

Method Detail

configsource public

config( )

Get the configuration data used to create the connection.

Returns

array
array

configNamesource public

configName( )

Get the configuration name for this connection.

Returns

string
string

disableConstraintssource public

disableConstraints( callable $operation )

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.

Returns

mixed
The return value of the callback.

Throws

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

logQueriessource public

logQueries( boolean $enable null )

Enables or disables query logging for this connection.

Parameters

boolean $enable optional null
whether to turn logging on or disable it. Use null to read current value.

Returns

boolean
bool

loggersource public

logger( object $instance null )

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

Parameters

object $instance optional null
logger object instance

Returns

object
logger instance

transactionalsource public

transactional( callable $transaction )

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.

Returns

mixed
The return value of the callback.

Throws

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

© 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/3.1/class-Cake.Datasource.ConnectionInterface.html