Class Connection
Property Summary
-
$_client protected
Elastica\Client
Elastica client instance
-
$_esLogger protected
Cake\ElasticSearch\Datasource\Log\ElasticLogger
Instance of ElasticLogger
-
$_logger protected
Cake\Database\Log\QueryLogger|Psr\Log\LoggerInterface
Logger object instance.
-
$configName protected
string
The connection name in the connection manager.
-
$logQueries protected
bool
Whether or not query logging is enabled.
Method Summary
-
__call() public
Pass remaining methods to the elastica client (if they exist) And set the current logger based on current logQueries value
-
__construct() public
Constructor.
-
beginTransaction() public
{@inheritDoc}
-
config() public
Get the config data for this connection.
-
configName() public
Get the configuration name for this connection.
-
disableConstraints() public
Run an operation with constraints disabled.
-
disableForeignKeys() public
{@inheritDoc}
-
disableQueryLogging() public @method
-
disableSavePoints() public @method
-
enableForeignKeys() public
{@inheritDoc}
-
enableQueryLogging() public @method
-
enabled() public
{@inheritDoc}
-
execute() public @method
-
getDriver() public @method
Gets the driver instance.
-
getEsLogger() public
Return instance of ElasticLogger
-
getLogger() public
Get the logger object Will set the default logger to elasticsearch if found, or debug If none of the above are found the default Es logger will be used.
-
getSchemaCollection() public
Returns a SchemaCollection stub until we can add more abstract API's in Connection.
-
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
Sets a 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
__call() ¶ public
__call(string $name, array $attributes): mixed
Pass remaining methods to the elastica client (if they exist) And set the current logger based on current logQueries value
Parameters
-
string
$name Method name
-
array
$attributes Method attributes
Returns
mixed
__construct() ¶ public
__construct(array $config = [], callable $callback = null)
Constructor.
Parameters
-
array
$config optional config options
-
callable
$callback optional Callback function which can be used to be notified about errors (for example connection down)
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.
Elasticsearch does not deal with the concept of foreign key constraints This method just triggers the $operation argument.
Parameters
-
callable
$operation
Returns
mixed
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
getEsLogger() ¶ public
getEsLogger(): Cake\ElasticSearch\Datasource\Log\ElasticLogger
Return instance of ElasticLogger
Returns
Cake\ElasticSearch\Datasource\Log\ElasticLogger
getLogger() ¶ public
getLogger(): Cake\Database\Log\QueryLogger
Get the logger object Will set the default logger to elasticsearch if found, or debug If none of the above are found the default Es logger will be used.
Returns
Cake\Database\Log\QueryLogger
getSchemaCollection() ¶ public
getSchemaCollection(): Cake\ElasticSearch\Datasource\SchemaCollection
Returns a SchemaCollection stub until we can add more abstract API's in Connection.
Returns
Cake\ElasticSearch\Datasource\SchemaCollection
logQueries() ¶ public
logQueries(bool|null $enable = null): bool
Enables or disables query logging for this connection.
Parameters
-
bool|null
$enable optional
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
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
setLogger(mixed $logger): $this
Sets a logger
Parameters
-
$logger
Logger instance
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
Returns
mixed