interface Session (View source)

A session is used to prepare and execute statements.

Methods

execute(string|Statement $statement, array|ExecutionOptions|null $options)

Execute a query.

executeAsync(string|Statement $statement, array|ExecutionOptions|null $options)

Execute a query asynchronously. This method returns immediately, but the query continues execution in the background.

prepare(string $cql, array|ExecutionOptions|null $options)

Prepare a query for execution.

prepareAsync(string $cql, array|ExecutionOptions|null $options)

Asynchronously prepare a query for execution.

null
close(float $timeout)

Close the session and all its connections.

closeAsync()

Asynchronously close the session and all its connections.

array
metrics()

Get performance and diagnostic metrics.

schema()

Get a snapshot of the cluster's current schema.

Details

Rows execute(string|Statement $statement, array|ExecutionOptions|null $options)

Execute a query.

Available execution options: Option Name Option Type Option Details
arguments array An array or positional or named arguments
consistency int A consistency constant e.g Dse::CONSISTENCY_ONE, Dse::CONSISTENCY_QUORUM, etc.
timeout int A number of rows to include in result for paging
paging_state_token string A string token use to resume from the state of a previous result set
retry_policy RetryPolicy A retry policy that is used to handle server-side failures for this request
serial_consistency int Either Dse::CONSISTENCY_SERIAL or Dse::CONSISTENCY_LOCAL_SERIAL
timestamp int|string Either an integer or integer string timestamp that represents the number of microseconds since the epoch
execute_as string User to execute statement as

Parameters

string|Statement $statement

string or statement to be executed.

array|ExecutionOptions|null $options

Options to control execution of the query.

Return Value

Rows

A collection of rows.

Exceptions

Exception

FutureRows executeAsync(string|Statement $statement, array|ExecutionOptions|null $options)

Execute a query asynchronously. This method returns immediately, but the query continues execution in the background.

Parameters

string|Statement $statement

string or statement to be executed.

array|ExecutionOptions|null $options

Options to control execution of the query.

Return Value

FutureRows

A future that can be used to retrieve the result.

See also

Session::execute for valid execution options

PreparedStatement prepare(string $cql, array|ExecutionOptions|null $options)

Prepare a query for execution.

Parameters

string $cql

The query to be prepared.

array|ExecutionOptions|null $options

Options to control preparing the query.

Return Value

PreparedStatement

A prepared statement that can be bound with parameters and executed.

Exceptions

Exception

See also

Session::execute for valid execution options

FuturePreparedStatement prepareAsync(string $cql, array|ExecutionOptions|null $options)

Asynchronously prepare a query for execution.

Parameters

string $cql

The query to be prepared.

array|ExecutionOptions|null $options

Options to control preparing the query.

Return Value

FuturePreparedStatement

A future that can be used to retrieve the prepared statement.

See also

Session::execute for valid execution options

null close(float $timeout)

Close the session and all its connections.

Parameters

float $timeout

The amount of time in seconds to wait for the session to close.

Return Value

null Nothing.

Exceptions

Exception

FutureClose closeAsync()

Asynchronously close the session and all its connections.

Return Value

FutureClose

A future that can be waited on.

array metrics()

Get performance and diagnostic metrics.

Return Value

array

Performance/Diagnostic metrics.

Schema schema()

Get a snapshot of the cluster's current schema.

Return Value

Schema

A snapshot of the cluster's schema.