Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions src/ClickHouseStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,23 +321,27 @@ public function getSql() : string
/**
* Specific SMI2 ClickHouse lib statement execution
* If you want to use any other lib for working with CH -- just update this method
*
* @param string $sql
*/
protected function processViaSMI2(string $sql) : void
{
$sql = trim($sql);

$this->rows =
stripos($sql, 'select') === 0 ||
stripos($sql, 'show') === 0 ||
stripos($sql, 'describe') === 0 ?
$this->smi2CHClient->select($sql)->rows() :
$this->smi2CHClient->write($sql)->rows();
if (stripos($sql, 'select') !== 0 && stripos($sql, 'show') !== 0 && stripos($sql, 'describe') !== 0) {
$this->rows = $this->smi2CHClient->write($sql)->rows();
return;
}

$this->rows = $this->smi2CHClient->select($sql)->rows();
$totals = $this->smi2CHClient->select($sql)->totals();
if (null !== $totals) {
$this->rows = array_merge($this->rows, ['totals' => $totals]);
}
}

/**
* @param string|int $key
* @throws ClickHouseException
* @return string
*/
protected function getTypedParam($key) : string
{
Expand Down