Skip to content

Commit 90fc34f

Browse files
committed
Implement PDOStatement::setFetchMode()
1 parent e6780f3 commit 90fc34f

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

wp-includes/sqlite-ast/class-wp-pdo-synthetic-statement.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ trait WP_PDO_Synthetic_Statement_PHP_Compat {
3535
* @return bool True on success, false on failure.
3636
*/
3737
public function setFetchMode( $mode, $params = null ): bool {
38-
throw new RuntimeException( 'Not implemented' );
38+
return $this->setDefaultFetchMode( $mode, $params );
3939
}
4040

4141
/**
@@ -61,8 +61,7 @@ trait WP_PDO_Synthetic_Statement_PHP_Compat {
6161
*/
6262
#[ReturnTypeWillChange]
6363
public function setFetchMode( $mode, ...$args ): bool {
64-
$this->fetch_mode = $mode;
65-
return true;
64+
return $this->setDefaultFetchMode( $mode, $args );
6665
}
6766

6867
/**
@@ -476,6 +475,22 @@ private function fetchAllRows( $mode = null, ...$args ): array {
476475
}
477476
return $rows;
478477
}
478+
479+
/**
480+
* Set the default fetch mode for this statement.
481+
*
482+
* This is used internally by the "WP_PDO_Synthetic_Statement_PHP_Compat"
483+
* trait, that is defined conditionally based on the current PHP version.
484+
*
485+
* @param int $mode The fetch mode to set as the default.
486+
* @param mixed $args Additional parameters for the default fetch mode.
487+
* @return bool True on success, false on failure.
488+
*/
489+
private function setDefaultFetchMode( $mode, ...$args ): bool {
490+
$this->fetch_mode = $mode;
491+
$this->fetch_mode_args = $args;
492+
return true;
493+
}
479494
}
480495

481496
/**

0 commit comments

Comments
 (0)