This interface defines the methods you can depend on in a connection.
Get the configuration data used to create the connection.
Get the configuration name for this connection.
Run an operation with constraints disabled.
Disable query logging
Enable/disable query logging
Executes a query using $params for interpolating values and $types as a hint for each those params. {@see \Cake\Database\Connnection::execute()}
Get a cacher.
Gets the driver instance. {@see \Cake\Database\Connnection::getDriver()}
Gets the current logger object.
Gets a Schema\Collection object for this connection. {@see \Cake\Database\Connnection::getSchemaCollection()}
Check if query logging is enabled.
Create a new Query instance for this connection. {@see \Cake\Database\Connnection::newQuery()}
Prepares a SQL statement to be executed. {@see \Cake\Database\Connnection::prepare()}
Executes a SQL statement and returns the Statement object as result. {@see \Cake\Database\Connnection::query()}
Set a cacher.
Set the current logger. {@see \Cake\Database\Connnection::setLogger()}
Returns whether the driver supports adding or dropping constraints to already created tables. {@see \Cake\Database\Connnection::supportsDynamicConstraints()}
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.
config(): array<string, mixed>
Get the configuration data used to create the connection.
array<string, mixed>configName(): string
Get the configuration name for this connection.
stringdisableConstraints(callable $callback): mixed
Run an operation with constraints disabled.
Constraints should be re-enabled after the callback succeeds/fails.
$connection->disableConstraints(function ($connection) {
$connection->newQuery()->delete('users')->execute();
}); callable $callback The callback to execute within a transaction.
mixedExceptiondisableQueryLogging(): $this
Disable query logging
$thisenableQueryLogging(bool $enable = true): $this
Enable/disable query logging
bool $enable optional Enable/disable query logging
$thisexecute(mixed $query, mixed $params = [], array $types = []): Cake\Database\StatementInterface
Executes a query using $params for interpolating values and $types as a hint for each those params. {@see \Cake\Database\Connnection::execute()}
array $types optional Cake\Database\StatementInterfacegetCacher(): Psr\SimpleCache\CacheInterface
Get a cacher.
Psr\SimpleCache\CacheInterfacegetDriver(): object
Gets the driver instance. {@see \Cake\Database\Connnection::getDriver()}
objectgetLogger(): Psr\Log\LoggerInterface
Gets the current logger object.
Psr\Log\LoggerInterfacegetSchemaCollection(): Cake\Database\Schema\Collection
Gets a Schema\Collection object for this connection. {@see \Cake\Database\Connnection::getSchemaCollection()}
Cake\Database\Schema\CollectionisQueryLoggingEnabled(): bool
Check if query logging is enabled.
boolnewQuery(): Cake\Database\Query
Create a new Query instance for this connection. {@see \Cake\Database\Connnection::newQuery()}
Cake\Database\Queryprepare(mixed $sql): Cake\Database\StatementInterface
Prepares a SQL statement to be executed. {@see \Cake\Database\Connnection::prepare()}
Cake\Database\StatementInterfacequery(string $sql): Cake\Database\StatementInterface
Executes a SQL statement and returns the Statement object as result. {@see \Cake\Database\Connnection::query()}
string $sql Cake\Database\StatementInterfacesetCacher(Psr\SimpleCache\CacheInterface $cacher): $this
Set a cacher.
Psr\SimpleCache\CacheInterface $cacher Cacher object
$thissetLogger(LoggerInterface $logger): void
Set the current logger. {@see \Cake\Database\Connnection::setLogger()}
LoggerInterface $logger voidsupportsDynamicConstraints(): bool
Returns whether the driver supports adding or dropping constraints to already created tables. {@see \Cake\Database\Connnection::supportsDynamicConstraints()}
booltransactional(callable $callback): 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.
$connection->transactional(function ($connection) {
$connection->newQuery()->delete('users')->execute();
}); callable $callback The callback to execute within a transaction.
mixedException
© 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/4.4/interface-Cake.Datasource.ConnectionInterface.html