Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/FakePdoStatementTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ function ($row) use ($fetch_argument, $ctor_args) {
/**
* @param int $fetch_style
* @param mixed $args
* @return true
*/
public function universalSetFetchMode(int $mode, ...$args) : bool
{
Expand Down
2 changes: 2 additions & 0 deletions src/Php8/FakePdoStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ public function fetchAll(int $fetch_style = -123, ...$args) : array
/**
* @param int $fetch_style
* @param mixed $args
* @return true
*/
#[\ReturnTypeWillChange]
public function setFetchMode(int $mode, ...$args) : bool
{
return $this->universalSetFetchMode($mode, ...$args);
Expand Down
15 changes: 15 additions & 0 deletions tests/FakePdoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ public function testMinimalTransaction(): void
self::assertFalse($pdo->inTransaction());
}

public function testSetFetchMode(): void
{
$pdo = self::getPdo('mysql:foo;dbname=test;');
$pdo->prepare('CREATE TABLE `foo` (`id` INT NOT NULL, PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci')->execute();
$pdo->prepare('INSERT INTO `foo` (`id`) VALUES (1)')->execute();

$statement = $pdo->prepare('SELECT `id` FROM `foo`');

self::assertTrue($statement->setFetchMode(\PDO::FETCH_ASSOC));

$statement->execute();

self::assertSame([['id' => '1']], $statement->fetchAll());
}

/**
* @dataProvider quotationStringProvider
*/
Expand Down
Loading