浏览代码

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.
Visman 3 年之前
父节点
当前提交
2073aceed7
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      app/Core/DB/AbstractStatement.php

+ 9 - 1
app/Core/DB/AbstractStatement.php

@@ -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;
     }