Skip to content

Commit

Permalink
Merge pull request #48 from vimeo/make-sure-fetch-default-is-defined
Browse files Browse the repository at this point in the history
Make Sure PDO::FETCH_DEFAULT is Defined
  • Loading branch information
sergiosalvatore authored Jul 8, 2024
2 parents 9573a8e + 3c90060 commit 3ae9c6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/FakePdoStatementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions tests/EndToEndTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 3ae9c6c

Please sign in to comment.