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:
parent
0d443ff683
commit
2073aceed7
1 changed files with 9 additions and 1 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue