Skip to content

Commit 5649e82

Browse files
committed
When using FETCH_DEFAULT, instead of setting the mode to a default value, it was modified so that the default value is not overridden.
1 parent a6566e7 commit 5649e82

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

ext/pdo/pdo_stmt.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,7 +1626,7 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
16261626

16271627
pdo_stmt_free_default_fetch_mode(stmt);
16281628

1629-
stmt->default_fetch_type = PDO_FETCH_BOTH;
1629+
stmt->default_fetch_type = stmt->dbh->default_fetch_type;
16301630

16311631
flags = mode & PDO_FETCH_FLAGS;
16321632

@@ -1638,6 +1638,8 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
16381638
return false;
16391639
}
16401640

1641+
bool use_default = (mode & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT;
1642+
16411643
switch (mode & ~PDO_FETCH_FLAGS) {
16421644
case PDO_FETCH_USE_DEFAULT:
16431645
case PDO_FETCH_LAZY:
@@ -1754,7 +1756,9 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
17541756
return false;
17551757
}
17561758

1757-
stmt->default_fetch_type = mode;
1759+
if (!use_default) {
1760+
stmt->default_fetch_type = mode;
1761+
}
17581762

17591763
return true;
17601764
}

0 commit comments

Comments
 (0)