Skip to content

Commit cdb7e79

Browse files
author
Митрофанов Николай
committed
refactor ClickHouseStatement fetch
1 parent eb85f4c commit cdb7e79

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/ClickHouseStatement.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ protected function assumeFetchMode($fetchMode = null)
141141
public function fetch($fetchMode = null)
142142
{
143143
$data = $this->getIterator()->current();
144+
145+
if (null === $data) {
146+
return false;
147+
}
148+
144149
$this->getIterator()->next();
145150

146151
if (\PDO::FETCH_NUM === $this->assumeFetchMode($fetchMode)) {
@@ -215,8 +220,7 @@ function ($row) {
215220
*/
216221
public function fetchColumn($columnIndex = 0)
217222
{
218-
if ($elem = $this->fetch()) {
219-
$elem = array_values($elem);
223+
if ($elem = $this->fetch(\PDO::FETCH_NUM)) {
220224

221225
return isset($elem[$columnIndex]) ? $elem[$columnIndex] : $elem[0];
222226
}

0 commit comments

Comments
 (0)