Interface ConnectionInterface
This interface defines the methods you can depend on in a connection.
Method Summary
-
config() public
Get the configuration data used to create the connection.
-
configName() public
Get the configuration name for this connection.
-
disableConstraints() public
Run an operation with constraints disabled.
-
disableQueryLogging() public @method
-
disableSavePoints() public @method
-
enableQueryLogging() public @method
-
execute() public @method
-
getLogger() public @method
Get the current logger instance
-
getSchemaCollection() public @method
-
isQueryLoggingEnabled() public @method
-
logQueries() public
Enables or disables query logging for this connection.
-
logger() public deprecated
Sets the logger object instance. When called with no arguments it returns the currently setup logger instance.
-
newQuery() public @method
-
prepare() public @method
-
query() public @method
-
quote() public @method
-
setLogger() public @method
Set the current logger.
-
supportsDynamicConstraints() public @method
-
transactional() public
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.
Method Detail
config() ¶ public
config(): array
Get the configuration data used to create the connection.
Returns
array
configName() ¶ public
configName(): string
Get the configuration name for this connection.
Returns
string
disableConstraints() ¶ public
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.
Returns
mixed
Throws
Exception
Will re-throw any exception raised in $callback after rolling back the transaction.
enableQueryLogging() ¶ public @method
enableQueryLogging(mixed $value): $this
Parameters
-
$value
Returns
$this
execute() ¶ public @method
execute(mixed $query, mixed $params = [], array $types = []): Cake\Database\StatementInterface
Parameters
-
$query
-
$params optional
-
array
$types optional
Returns
Cake\Database\StatementInterface
getSchemaCollection() ¶ public @method
getSchemaCollection(): Cake\Database\Schema\Collection
Returns
Cake\Database\Schema\Collection
logQueries() ¶ public
logQueries(bool|null $enable = null): bool
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(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 optional logger object instance
Returns
object
prepare() ¶ public @method
prepare(mixed $sql): Cake\Database\StatementInterface
Parameters
-
$sql
Returns
Cake\Database\StatementInterface
query() ¶ public @method
query(string $sql): Cake\Database\StatementInterface
Parameters
-
string
$sql
Returns
Cake\Database\StatementInterface
quote() ¶ public @method
quote(mixed $value, mixed $type = null): string
Parameters
-
$value
-
$type optional
Returns
string
setLogger() ¶ public @method
setLogger(mixed $logger): $this
Set the current logger.
Parameters
-
$logger
Returns
$this
transactional() ¶ public
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.
Returns
mixed
Throws
Exception
Will re-throw any exception raised in $callback after rolling back the transaction.