Skip to content

Commit 1295b5f

Browse files
authored
Merge pull request #5909 from phansys/last_insert_id
Fix type assumptions about `Connection::lastInsertId()`
2 parents c84d330 + aec9b17 commit 1295b5f

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

src/Connection.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -878,8 +878,6 @@ public function getTransactionNestingLevel(): int
878878
*
879879
* If the underlying driver does not support identity columns, an exception is thrown.
880880
*
881-
* @return int|string The last insert ID, as an integer or a numeric string.
882-
*
883881
* @throws Exception
884882
*/
885883
public function lastInsertId(): int|string

src/Driver/Connection.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,16 @@ public function exec(string $sql): int|string;
4646
/**
4747
* Returns the ID of the last inserted row.
4848
*
49-
* This method returns an integer or a numeric string representing the value of the auto-increment column
49+
* This method returns an integer or a string representing the value of the auto-increment column
5050
* from the last row inserted into the database, if any, or throws an exception if a value cannot be returned,
5151
* in particular when:
5252
*
5353
* - the driver does not support identity columns;
5454
* - the last statement dit not return an identity (caution: see note below).
5555
*
5656
* Note: if the last statement was not an INSERT to an autoincrement column, this method MAY return an ID from a
57-
* previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always use getLastInsertId() right
58-
* after executing an INSERT statement.
59-
*
60-
* @return int|string The last insert ID, as an integer or a numeric string.
57+
* previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always call this method right after
58+
* executing an INSERT statement.
6159
*
6260
* @throws Exception
6361
*/

src/Driver/IBMDB2/Connection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function exec(string $sql): int|string
7777
return db2_num_rows($stmt);
7878
}
7979

80-
public function lastInsertId(): int|string
80+
public function lastInsertId(): string
8181
{
8282
$lastInsertId = db2_last_insert_id($this->connection);
8383

0 commit comments

Comments
 (0)