Interface ConnectionInterface

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

Namespace: Cake\Datasource

Method Summary

Method Detail

config() public

config()

Get the configuration data used to create the connection.

Returns

array

configName() public

configName()

Get the configuration name for this connection.

Returns

string

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

disableQueryLogging() public

disableQueryLogging()

disableSavePoints() public

disableSavePoints()

enableQueryLogging() public

enableQueryLogging(mixed $value)

Parameters

mixed $value

execute() public

execute(mixed $query, mixed $params, array $types = [])

Parameters

mixed $query
mixed $params
array $types = []

getDriver() public

getDriver()

Gets the driver instance.

getLogger() public

getLogger()

Get the current logger instance

getSchemaCollection() public

getSchemaCollection()

isQueryLoggingEnabled() public

isQueryLoggingEnabled()

logQueries() public

logQueries(mixed $enable)

Enables or disables query logging for this connection.

Parameters

bool|null $enable optional

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

Returns

bool

logger() public

logger(mixed $instance)

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

Parameters

object|null $instance optional

logger object instance

Returns

object

logger instance

newQuery() public

newQuery()

prepare() public

prepare(mixed $sql)

Parameters

mixed $sql

query() public

query(string $sql)

Parameters

string $sql

quote() public

quote(mixed $value, mixed $type)

Parameters

mixed $value
mixed $type

setLogger() public

setLogger(mixed $logger)

Set the current logger.

Parameters

mixed $logger

supportsDynamicConstraints() public

supportsDynamicConstraints()

transactional() 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–present 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.
https://api.cakephp.org/3.9/interface-Cake.Datasource.ConnectionInterface.html