CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C Elastic Search 3.x API

  • Project:
    • Elastic Search
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 3.x
      • 4.x
      • 3.x
      • 2.x

Namespaces

  • Cake\ElasticSearch
    • Association
    • Datasource
      • Log
    • Exception
    • Rule
    • TestSuite
    • View

Class Connection

Namespace: Cake\ElasticSearch\Datasource

Constants

  • string
    ROLE_READ ¶
    'read'
  • string
    ROLE_WRITE ¶
    'write'

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
  • 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
  • disableQueryLogging() public

    Disable query logging

  • enableForeignKeys() public
  • enableQueryLogging() public

    Enable/disable query logging

  • enabled() public
  • execute() public

    Executes a query using $params for interpolating values and $types as a hint for each those params. {@see \Cake\Database\Connnection::execute()}

  • getCacher() public

    Get a cacher.

  • getDriver() public

    Gets the driver instance. {@see \Cake\Database\Connnection::getDriver()}

  • getEsLogger() public

    Return instance of ElasticLogger

  • getIndex() public

    Returns the index for the given connection

  • 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

    Check if query logging is enabled.

  • newQuery() public

    {@inheritDoc}

  • prepare() public

    Prepares a SQL statement to be executed. {@see \Cake\Database\Connnection::prepare()}

  • query() public

    Executes a SQL statement and returns the Statement object as result. {@see \Cake\Database\Connnection::query()}

  • setCacher() public

    Set a cacher.

  • setLogger() public

    Sets a logger

  • supportsDynamicConstraints() public

    Returns whether the driver supports adding or dropping constraints to already created tables. {@see \Cake\Database\Connnection::supportsDynamicConstraints()}

  • 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)

beginTransaction() ¶ public

beginTransaction()

config() ¶ public

config(): array

Get the config data for this 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.

Elasticsearch does not deal with the concept of foreign key constraints This method just triggers the $callback argument.

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.

disableForeignKeys() ¶ public

disableForeignKeys()

disableQueryLogging() ¶ public

disableQueryLogging(): $this

Disable query logging

Returns
$this

enableForeignKeys() ¶ public

enableForeignKeys()

enableQueryLogging() ¶ public

enableQueryLogging(bool $value = true): $this

Enable/disable query logging

Parameters
bool $value optional

Enable/disable query logging

Returns
$this

enabled() ¶ public

enabled()

execute() ¶ public

execute(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()}

Parameters
$query
$params optional
array $types optional
Returns
Cake\Database\StatementInterface

getCacher() ¶ public

getCacher(): Psr\SimpleCache\CacheInterface

Get a cacher.

Returns
Psr\SimpleCache\CacheInterface

getDriver() ¶ public

getDriver(): Elastica\Client

Gets the driver instance. {@see \Cake\Database\Connnection::getDriver()}

Returns
Elastica\Client
See Also
\Cake\Datasource\ConnectionInterface::getDriver()

getEsLogger() ¶ public

getEsLogger(): Cake\ElasticSearch\Datasource\Log\ElasticLogger

Return instance of ElasticLogger

Returns
Cake\ElasticSearch\Datasource\Log\ElasticLogger

getIndex() ¶ public

getIndex(string $name = null): Elastica\Index

Returns the index for the given connection

Parameters
string $name optional

Index name to create connection to, if no value is passed it will use the default index name for the connection.

Returns
Elastica\Index

getLogger() ¶ public

getLogger(): Psr\Log\LoggerInterface

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
Psr\Log\LoggerInterface

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

isQueryLoggingEnabled() ¶ public

isQueryLoggingEnabled(): bool

Check if query logging is enabled.

Returns
bool

newQuery() ¶ public

newQuery(): Elastica\Query\BoolQuery

{@inheritDoc}

Returns
Elastica\Query\BoolQuery
See Also
\Cake\Datasource\ConnectionInterface::newQuery()

prepare() ¶ public

prepare(mixed $sql): Cake\Database\StatementInterface

Prepares a SQL statement to be executed. {@see \Cake\Database\Connnection::prepare()}

Parameters
$sql
Returns
Cake\Database\StatementInterface

query() ¶ public

query(string $sql): Cake\Database\StatementInterface

Executes a SQL statement and returns the Statement object as result. {@see \Cake\Database\Connnection::query()}

Parameters
string $sql
Returns
Cake\Database\StatementInterface

setCacher() ¶ public

setCacher(Psr\SimpleCache\CacheInterface $cacher): $this

Set a cacher.

Parameters
Psr\SimpleCache\CacheInterface $cacher
Returns
$this

setLogger() ¶ public

setLogger(LoggerInterface $logger): $this

Sets a logger

Parameters
LoggerInterface $logger

Logger instance

Returns
$this

supportsDynamicConstraints() ¶ public

supportsDynamicConstraints(): bool

Returns whether the driver supports adding or dropping constraints to already created tables. {@see \Cake\Database\Connnection::supportsDynamicConstraints()}

Returns
bool
See Also
\Cake\Datasource\ConnectionInterface::supportsDynamicConstraints()

transactional() ¶ public

transactional(callable $callable): 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.

Example:

$connection->transactional(function ($connection) {
  $connection->newQuery()->delete('users')->execute();
});
Parameters
callable $callable
Returns
mixed

Property Detail

$_client ¶ protected

Elastica client instance

Type
Elastica\Client

$_esLogger ¶ protected

Instance of ElasticLogger

Type
Cake\ElasticSearch\Datasource\Log\ElasticLogger

$_logger ¶ protected

Logger object instance.

Type
Cake\Database\Log\QueryLogger|Psr\Log\LoggerInterface

$configName ¶ protected

The connection name in the connection manager.

Type
string

$logQueries ¶ protected

Whether or not query logging is enabled.

Type
bool
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs