Update DB\AbstractStatement #9

In the case of -> fetch (PDO :: FETCH_COLUMN), the method should return the value from the first column of the row, not an array with the data of all columns of the row.
This commit is contained in:
Visman 2021-12-16 13:09:23 +07:00
parent 0d443ff683
commit 2073aceed7

View file

@ -29,7 +29,11 @@ abstract class AbstractStatement extends DBStatement
protected function dbFetch(int $mode, int $cursorOrientation, int $cursorOffset) /* : mixed */
{
$data = parent::fetch($mode, $cursorOrientation, $cursorOffset);
$data = parent::fetch(
PDO::FETCH_COLUMN === $mode ? PDO::FETCH_NUM : $mode,
$cursorOrientation,
$cursorOffset
);
if (! \is_array($data)) {
return $data;
@ -61,6 +65,10 @@ abstract class AbstractStatement extends DBStatement
unset($value);
if (PDO::FETCH_COLUMN === $mode) {
$data = $data[0];
}
return $data;
}