diff --git a/src/FakePdoStatementTrait.php b/src/FakePdoStatementTrait.php index 71151103..06603c89 100644 --- a/src/FakePdoStatementTrait.php +++ b/src/FakePdoStatementTrait.php @@ -339,7 +339,7 @@ public function fetch( $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset = 0 ) { - if ($fetch_style === -123) { + if ($fetch_style === -123 || $fetch_style === \PDO::FETCH_DEFAULT) { $fetch_style = $this->fetchMode; } @@ -415,7 +415,7 @@ public function fetchColumn($column = 0) */ public function universalFetchAll(int $fetch_style = -123, ...$args) : array { - if ($fetch_style === -123) { + if ($fetch_style === -123 || $fetch_style === \PDO::FETCH_DEFAULT) { $fetch_style = $this->fetchMode; $fetch_argument = $this->fetchArgument; $ctor_args = $this->fetchConstructorArgs; diff --git a/tests/EndToEndTest.php b/tests/EndToEndTest.php index 262f9653..ab64ef53 100644 --- a/tests/EndToEndTest.php +++ b/tests/EndToEndTest.php @@ -34,6 +34,28 @@ public function testInvalidQuery() $this->assertSame([], $query->fetchAll(\PDO::FETCH_ASSOC)); } + public function testSelectFetchDefault() + { + $pdo = self::getConnectionToFullDB(); + + $query = $pdo->prepare("SELECT id FROM `video_game_characters` WHERE `id` > :id ORDER BY `id` ASC"); + $query->bindValue(':id', 14); + $query->execute(); + + $this->assertSame( + ['id' => '15', 0 => '15'], + $query->fetch(\PDO::FETCH_DEFAULT) + ); + + $this->assertSame( + [ + ['id' => '15', 0 => '15'], + ['id' => '16', 0 => '16'] + ], + $query->fetchAll(\PDO::FETCH_DEFAULT) + ); + } + public function testSelectFetchAssoc() { $pdo = self::getConnectionToFullDB();