Cassandra\Session::prepare PHP Method

prepare() public method

Note that this method only uses the ExecutionOptions::$timeout option, all other options will be ignored.
public prepare ( string $cql, ExecutionOptions $options = null ) : PreparedStatement
$cql string CQL statement string
$options ExecutionOptions execution options (optional)
return PreparedStatement prepared statement
    public function prepare($cql, ExecutionOptions $options = null);

Usage Example

 /**
  * {@inheritDoc}
  */
 public function find($storageName, $key)
 {
     $where = [];
     foreach ($key as $name => $value) {
         $where[] = $name . ' = ?';
     }
     $stmt = $this->session->prepare('SELECT * FROM ' . $storageName . ' WHERE ' . implode(' AND ', $where));
     $options = new ExecutionOptions(['arguments' => array_values($key)]);
     $result = $this->session->execute($stmt, $options);
     $rows = iterator_to_array($result);
     if (!isset($rows[0])) {
         throw new NotFoundException();
     }
     $data = [];
     foreach ($rows[0] as $column => $value) {
         if (isset($key[$column])) {
             continue;
         }
         $data[$column] = $value;
     }
     return $data;
 }