Skip to content

Commit

Permalink
Fix type assumptions about Connection::lastInsertId()
Browse files Browse the repository at this point in the history
  • Loading branch information
phansys committed Feb 7, 2023
1 parent e543ade commit aec9b17
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
2 changes: 0 additions & 2 deletions src/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,6 @@ public function getTransactionNestingLevel(): int
*
* If the underlying driver does not support identity columns, an exception is thrown.
*
* @return int|string The last insert ID, as an integer or a numeric string.
*
* @throws Exception
*/
public function lastInsertId(): int|string
Expand Down
8 changes: 3 additions & 5 deletions src/Driver/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,16 @@ public function exec(string $sql): int|string;
/**
* Returns the ID of the last inserted row.
*
* This method returns an integer or a numeric string representing the value of the auto-increment column
* This method returns an integer or a string representing the value of the auto-increment column
* from the last row inserted into the database, if any, or throws an exception if a value cannot be returned,
* in particular when:
*
* - the driver does not support identity columns;
* - the last statement dit not return an identity (caution: see note below).
*
* Note: if the last statement was not an INSERT to an autoincrement column, this method MAY return an ID from a
* previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always use getLastInsertId() right
* after executing an INSERT statement.
*
* @return int|string The last insert ID, as an integer or a numeric string.
* previous statement. DO NOT RELY ON THIS BEHAVIOR which is driver-dependent: always call this method right after
* executing an INSERT statement.
*
* @throws Exception
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Driver/IBMDB2/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public function exec(string $sql): int|string
return db2_num_rows($stmt);
}

public function lastInsertId(): int|string
public function lastInsertId(): string
{
$lastInsertId = db2_last_insert_id($this->connection);

Expand Down

0 comments on commit aec9b17

Please sign in to comment.