Interface ConnectionInterface
This interface defines the methods you can depend on in a connection.
Direct Implementers
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.
-
logQueries() publicEnables or disables query logging for this connection.
-
Sets the logger object instance. When called with no arguments it returns the currently setup logger instance.
-
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()source public
config( )
Get the configuration data used to create the connection.
Returns
arrayconfigName()source public
configName( )
Get the configuration name for this connection.
Returns
stringdisableConstraints()source 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
mixedThe return value of the callback.
Throws
ExceptionWill re-throw any exception raised in $callback after rolling back the transaction.
logQueries()source public
logQueries( boolean|null $enable = null )
Enables or disables query logging for this connection.
Parameters
-
boolean|null
$enable
optional null -
whether to turn logging on or disable it. Use null to read current value.
Returns
booleanlogger()source public deprecated
logger( object|null $instance = null )
Sets the logger object instance. When called with no arguments it returns the currently setup logger instance.
Deprecated
3.5.0 Will be replaced by getLogger()/setLogger()Parameters
-
object|null
$instance
optional null - logger object instance
Returns
objectlogger instance
transactional()source 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
mixedThe return value of the callback.
Throws
ExceptionWill re-throw any exception raised in $callback after rolling back the transaction.
Magic methods summary
execute()source public
execute( $query , $params = , array $types = )
Parameters
-
$query
-
$params
optional -
array
$types
optional
Returns
Cake\Database\StatementInterface
getLogger()source public
getLogger( )
Get the current logger instance
Returns
getSchemaCollection()source public
getSchemaCollection( )
Returns
Cake\Database\Schema\Collection
isQueryLoggingEnabled()source public
isQueryLoggingEnabled( )
Returns
newQuery()source public
newQuery( )
Returns
Cake\Database\Query
prepare()source public
prepare( $sql )
Parameters
-
$sql
Returns
Cake\Database\StatementInterface
quote()source public
quote( $value , $type = )
Parameters
-
$value
-
$type
optional
Returns
supportsDynamicConstraints()source public
supportsDynamicConstraints( )
Returns
© 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.7/class-Cake.Datasource.ConnectionInterface.html