Skip to content

Commit c5a2b40

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 7bd27e7 commit c5a2b40

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

ext/pdo/pdo_stmt.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,18 +1729,16 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
17291729
;
17301730
}
17311731

1732-
stmt->default_fetch_type = PDO_FETCH_BOTH;
1732+
stmt->default_fetch_type = stmt->dbh->default_fetch_type;
17331733

17341734
flags = mode & PDO_FETCH_FLAGS;
17351735

1736-
if ((mode & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT) {
1737-
mode = stmt->dbh->default_fetch_type | flags;
1738-
}
1739-
17401736
if (!pdo_stmt_verify_mode(stmt, mode, mode_arg_num, false)) {
17411737
return false;
17421738
}
17431739

1740+
bool use_default = (mode & ~PDO_FETCH_FLAGS) == PDO_FETCH_USE_DEFAULT;
1741+
17441742
switch (mode & ~PDO_FETCH_FLAGS) {
17451743
case PDO_FETCH_USE_DEFAULT:
17461744
case PDO_FETCH_LAZY:
@@ -1862,7 +1860,9 @@ bool pdo_stmt_setup_fetch_mode(pdo_stmt_t *stmt, zend_long mode, uint32_t mode_a
18621860
return false;
18631861
}
18641862

1865-
stmt->default_fetch_type = mode;
1863+
if (!use_default) {
1864+
stmt->default_fetch_type = mode;
1865+
}
18661866

18671867
return true;
18681868
}

0 commit comments

Comments
 (0)