Skip to content

Commit 6723b87

Browse files
committed
Connection::getInsertId() returns int|string (BC break)
1 parent 12ef39a commit 6723b87

3 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/Database/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public function setRowNormalizer(?callable $normalizer): static
138138
}
139139

140140

141-
public function getInsertId(?string $sequence = null): string
141+
public function getInsertId(?string $sequence = null): int|string
142142
{
143143
return $this->getConnectionDriver()->getInsertId($sequence);
144144
}

src/Database/Drivers/PDO/Connection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ public function rollBack(): void
115115
}
116116

117117

118-
public function getInsertId(?string $sequence = null): string
118+
public function getInsertId(?string $sequence = null): int|string
119119
{
120120
try {
121121
$res = $this->pdo->lastInsertId($sequence);
122-
return $res === false ? '0' : $res;
122+
return $res === false ? 0 : $res;
123123
} catch (PDOException $e) {
124124
throw new ($this->convertException($e, $args))(...$args);
125125
}

src/Database/Explorer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function transaction(callable $callback): mixed
5656
}
5757

5858

59-
public function getInsertId(?string $sequence = null): string
59+
public function getInsertId(?string $sequence = null): int|string
6060
{
6161
return $this->connection->getInsertId($sequence);
6262
}

0 commit comments

Comments
 (0)