1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 05:50:42 +02:00

[ticket/8071] Add sql_last_inserted_id alias for sql_nextid

Fixes [DBAL function sql_nextid - name is
misleading](https://tracker.phpbb.com/browse/PHPBB3-8071).

Per the tracker issue:
> This function gets the ID of the last inserted row, not the ID of the next row
to be inserted (which is difficult due to different autoincrement steps and also
lends itself nicely to race conditions).

@iwisdom replied that the naming is consistent with how PHP itself names this
functionality, but the link they posted doesn't support that (I guess this is
referring to a much older version of PHP? The comment is from 2009).

PHPBB3-8071
This commit is contained in:
lionel-rowe
2022-04-26 15:00:38 +01:00
parent a12a6f52ae
commit 9fb98201f2
8 changed files with 100 additions and 19 deletions

View File

@@ -289,13 +289,21 @@ class mysqli extends \phpbb\db\driver\mysql_base
}
/**
* {@inheritDoc}
*/
* {@inheritDoc}
*/
function sql_nextid()
{
return ($this->db_connect_id) ? @mysqli_insert_id($this->db_connect_id) : false;
}
/**
* {@inheritdoc}
*/
public function sql_last_inserted_id()
{
return $this->sql_nextid();
}
/**
* {@inheritDoc}
*/