diff --git a/src/FakePdoStatementTrait.php b/src/FakePdoStatementTrait.php index 06603c89..ce33ca36 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 || $fetch_style === \PDO::FETCH_DEFAULT) { + if ($fetch_style === -123 || (defined('PDO::FETCH_DEFAULT') && $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 || $fetch_style === \PDO::FETCH_DEFAULT) { + if ($fetch_style === -123 || (defined('PDO::FETCH_DEFAULT') && $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 e2790b56..b3ccc72e 100644 --- a/tests/EndToEndTest.php +++ b/tests/EndToEndTest.php @@ -54,6 +54,10 @@ public function testSelectWithDefaultFetchAssoc() public function testSelectFetchDefault() { + if (!defined('PDO::FETCH_DEFAULT')) { + $this->markTestSkipped('PHP version does not support PDO::FETCH_DEFAULT'); + } + $pdo = self::getConnectionToFullDB(); $query = $pdo->prepare("SELECT id FROM `video_game_characters` WHERE `id` > :id ORDER BY `id` ASC");