A session is used to prepare and execute statements.

See Also:

Implemented by

Methods

Cassandra\Rows

execute

( mixed $statement, mixed $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

Cassandra\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:
Name Type Details
$statement string|Cassandra\Statement

string or statement to be executed.

$options array|Cassandra\ExecutionOptions

Options to control execution of the query.

Throws:
Type Details
Cassandra\Exception
Returns:
Type Details
Cassandra\Rows

A collection of rows.

Cassandra\FutureRows

executeAsync

( mixed $statement, mixed $options )

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

Parameters:
Name Type Details
$statement string|Cassandra\Statement

string or statement to be executed.

$options array|Cassandra\ExecutionOptions

Options to control execution of the query.

Returns:
Type Details
Cassandra\FutureRows

A future that can be used to retrieve the result.

See Also:
Cassandra\PreparedStatement

prepare

( string $cql, mixed $options )

Prepare a query for execution.

Parameters:
Name Type Details
$cql string

The query to be prepared.

$options array|Cassandra\ExecutionOptions

Options to control preparing the query.

Throws:
Type Details
Cassandra\Exception
Returns:
Type Details
Cassandra\PreparedStatement

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

See Also:
Cassandra\FuturePreparedStatement

prepareAsync

( string $cql, mixed $options )

Asynchronously prepare a query for execution.

Parameters:
Name Type Details
$cql string

The query to be prepared.

$options array|Cassandra\ExecutionOptions

Options to control preparing the query.

Returns:
Type Details
Cassandra\FuturePreparedStatement

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

See Also:
null

close

( double $timeout )

Close the session and all its connections.

Parameters:
Name Type Details
$timeout double

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

Throws:
Type Details
Cassandra\Exception
Returns:
Type Details
null

Nothing.

Cassandra\FutureClose

closeAsync

( )

Asynchronously close the session and all its connections.

Returns:
Type Details
Cassandra\FutureClose

A future that can be waited on.

array

metrics

( )

Get performance and diagnostic metrics.

Returns:
Type Details
array

Performance/Diagnostic metrics.

Cassandra\Schema

schema

( )

Get a snapshot of the cluster’s current schema.

Returns:
Type Details
Cassandra\Schema

A snapshot of the cluster’s schema.