public function query($cql, array $values = [], $consistency = ConsistencyEnum::CONSISTENCY_QUORUM)
{
if ($this->batchQuery && in_array(substr($cql, 0, 6), ['INSERT', 'UPDATE', 'DELETE'])) {
$this->appendQueryToStack($cql, $values);
return true;
}
if (empty($values)) {
$response = $this->connection->sendRequest(RequestFactory::query($cql, $consistency));
} else {
$response = $this->connection->sendRequest(RequestFactory::prepare($cql));
$responseType = $response->getType();
if ($responseType !== OpcodeEnum::RESULT) {
throw new QueryException($response->getData());
} else {
$preparedData = $response->getData();
}
$response = $this->connection->sendRequest(RequestFactory::execute($preparedData, $values, $consistency));
}
if ($response->getType() === OpcodeEnum::ERROR) {
throw new CassandraException($response->getData());
} else {
$data = $response->getData();
if ($data instanceof Rows) {
return $data->asArray();
}
}
return !empty($data) ? $data : $response->getType() === OpcodeEnum::RESULT;
}