Skip to content

Commit 3ae9c6c

Browse files
Merge pull request #48 from vimeo/make-sure-fetch-default-is-defined
Make Sure PDO::FETCH_DEFAULT is Defined
2 parents 9573a8e + 3c90060 commit 3ae9c6c

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/FakePdoStatementTrait.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ public function fetch(
339339
$cursor_orientation = \PDO::FETCH_ORI_NEXT,
340340
$cursor_offset = 0
341341
) {
342-
if ($fetch_style === -123 || $fetch_style === \PDO::FETCH_DEFAULT) {
342+
if ($fetch_style === -123 || (defined('PDO::FETCH_DEFAULT') && $fetch_style === \PDO::FETCH_DEFAULT)) {
343343
$fetch_style = $this->fetchMode;
344344
}
345345

@@ -415,7 +415,7 @@ public function fetchColumn($column = 0)
415415
*/
416416
public function universalFetchAll(int $fetch_style = -123, ...$args) : array
417417
{
418-
if ($fetch_style === -123 || $fetch_style === \PDO::FETCH_DEFAULT) {
418+
if ($fetch_style === -123 || (defined('PDO::FETCH_DEFAULT') && $fetch_style === \PDO::FETCH_DEFAULT)) {
419419
$fetch_style = $this->fetchMode;
420420
$fetch_argument = $this->fetchArgument;
421421
$ctor_args = $this->fetchConstructorArgs;

tests/EndToEndTest.php

+4
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public function testSelectWithDefaultFetchAssoc()
5454

5555
public function testSelectFetchDefault()
5656
{
57+
if (!defined('PDO::FETCH_DEFAULT')) {
58+
$this->markTestSkipped('PHP version does not support PDO::FETCH_DEFAULT');
59+
}
60+
5761
$pdo = self::getConnectionToFullDB();
5862

5963
$query = $pdo->prepare("SELECT id FROM `video_game_characters` WHERE `id` > :id ORDER BY `id` ASC");

0 commit comments

Comments
 (0)