Interface ConnectionInterface
This interface defines the methods you can depend on in a connection.
Method Summary
- 
          config() publicGet the configuration data used to create the connection. 
- 
          configName() publicGet the configuration name for this connection. 
- 
          disableConstraints() publicRun an operation with constraints disabled. 
- 
          disableQueryLogging() publicDisable query logging 
- 
          enableQueryLogging() publicEnable/disable query logging 
- 
          execute() public @methodExecutes a query using $paramsfor interpolating values and $types as a hint for each those params. {@see \Cake\Database\Connnection::execute()}
- 
          getCacher() publicGet a cacher. 
- 
          getDriver() public @methodGets the driver instance. {@see \Cake\Database\Connnection::getDriver()} 
- 
          getLogger() publicGets the current logger object. 
- 
          getSchemaCollection() public @methodGets a Schema\Collection object for this connection. {@see \Cake\Database\Connnection::getSchemaCollection()} 
- 
          isQueryLoggingEnabled() publicCheck if query logging is enabled. 
- 
          newQuery() public @methodCreate a new Query instance for this connection. {@see \Cake\Database\Connnection::newQuery()} 
- 
          prepare() public @methodPrepares a SQL statement to be executed. {@see \Cake\Database\Connnection::prepare()} 
- 
          query() public @methodExecutes a SQL statement and returns the Statement object as result. {@see \Cake\Database\Connnection::query()} 
- 
          setCacher() publicSet a cacher. 
- 
          setLogger() public @methodSet the current logger. {@see \Cake\Database\Connnection::setLogger()} 
- 
          supportsDynamicConstraints() public @methodReturns whether the driver supports adding or dropping constraints to already created tables. {@see \Cake\Database\Connnection::supportsDynamicConstraints()} 
- 
          transactional() publicExecutes 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(): arrayGet the configuration data used to create the connection.
Returns
arrayconfigName() ¶ public
configName(): stringGet the configuration name for this connection.
Returns
stringdisableConstraints() ¶ public
disableConstraints(callable $callback): mixedRun an operation with constraints disabled.
Constraints should be re-enabled after the callback succeeds/fails.
Example:
$connection->disableConstraints(function ($connection) {
  $connection->newQuery()->delete('users')->execute();
});Parameters
- 
                callable$callback
- The callback to execute within a transaction. 
Returns
mixedThe return value of the callback.
Throws
ExceptionWill re-throw any exception raised in $callback after rolling back the transaction.
enableQueryLogging() ¶ public
enableQueryLogging(bool $enable = true): $thisEnable/disable query logging
Parameters
- 
                bool$enable optional
- Enable/disable query logging 
Returns
$thisexecute() ¶ public @method
execute(mixed $query, mixed $params = [], array $types = []): Cake\Database\StatementInterfaceExecutes a query using
$params for interpolating values and $types as a hint for each those params.
{@see \Cake\Database\Connnection::execute()}
Parameters
- 
                $query
- 
                $params optional
- 
                array$types optional
Returns
Cake\Database\StatementInterfacegetCacher() ¶ public
getCacher(): Psr\SimpleCache\CacheInterfaceGet a cacher.
Returns
Psr\SimpleCache\CacheInterface$cacher Cacher object
getDriver() ¶ public @method
getDriver(): objectGets the driver instance. {@see \Cake\Database\Connnection::getDriver()}
Returns
objectgetLogger() ¶ public
getLogger(): Psr\Log\LoggerInterfaceGets the current logger object.
Returns
Psr\Log\LoggerInterfacelogger instance
getSchemaCollection() ¶ public @method
getSchemaCollection(): Cake\Database\Schema\CollectionGets a Schema\Collection object for this connection. {@see \Cake\Database\Connnection::getSchemaCollection()}
Returns
Cake\Database\Schema\CollectionisQueryLoggingEnabled() ¶ public
isQueryLoggingEnabled(): boolCheck if query logging is enabled.
Returns
boolnewQuery() ¶ public @method
newQuery(): Cake\Database\QueryCreate a new Query instance for this connection. {@see \Cake\Database\Connnection::newQuery()}
Returns
Cake\Database\Queryprepare() ¶ public @method
prepare(mixed $sql): Cake\Database\StatementInterfacePrepares a SQL statement to be executed. {@see \Cake\Database\Connnection::prepare()}
Parameters
- 
                $sql
Returns
Cake\Database\StatementInterfacequery() ¶ public @method
query(string $sql): Cake\Database\StatementInterfaceExecutes a SQL statement and returns the Statement object as result. {@see \Cake\Database\Connnection::query()}
Parameters
- 
                string$sql
Returns
Cake\Database\StatementInterfacesetCacher() ¶ public
setCacher(Psr\SimpleCache\CacheInterface $cacher): $thisSet a cacher.
Parameters
- 
                Psr\SimpleCache\CacheInterface$cacher
- Cacher object 
Returns
$thissetLogger() ¶ public @method
setLogger(LoggerInterface $logger): voidSet the current logger. {@see \Cake\Database\Connnection::setLogger()}
Parameters
- 
                LoggerInterface$logger
Returns
voidsupportsDynamicConstraints() ¶ public @method
supportsDynamicConstraints(): boolReturns whether the driver supports adding or dropping constraints to already created tables. {@see \Cake\Database\Connnection::supportsDynamicConstraints()}
Returns
booltransactional() ¶ public
transactional(callable $callback): mixedExecutes 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.
Example:
$connection->transactional(function ($connection) {
  $connection->newQuery()->delete('users')->execute();
});Parameters
- 
                callable$callback
- The callback to execute within a transaction. 
Returns
mixedThe return value of the callback.
Throws
ExceptionWill re-throw any exception raised in $callback after rolling back the transaction.
