1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-06-04 21:44:57 +02:00

Merge pull request #6392 from lionel-rowe/ticket/8071

[ticket/8071] Add sql_last_inserted_id alias for sql_nextid
This commit is contained in:
Marc Alexander 2023-04-11 22:18:57 +02:00
commit 6e66f1505c
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
9 changed files with 63 additions and 25 deletions

View File

@ -634,6 +634,14 @@ abstract class driver implements driver_interface
return $expression;
}
/**
* {@inheritDoc}
*/
public function sql_nextid()
{
return $this->sql_last_inserted_id();
}
/**
* {@inheritDoc}
*/

View File

@ -289,12 +289,34 @@ interface driver_interface
public function cast_expr_to_bigint($expression);
/**
* Get last inserted id after insert statement
* Gets the ID of the **last** inserted row immediately after an INSERT
* statement.
*
* @return string Autoincrement value of the last inserted row
* **Note**: Despite the name, the returned ID refers to the row that has
* just been inserted, rather than the hypothetical ID of the next row if a
* new one was to be inserted.
*
* The returned value can be used for selecting the item that has just been
* inserted or for updating another table with an ID pointing to that item.
*
* Alias of `sql_last_inserted_id`.
*
* @deprecated 3.3.11-RC1 Replaced by sql_last_inserted_id(), to be removed in 4.1.0-a1
*
* @return string|false Auto-incremented value of the last inserted row
*/
public function sql_nextid();
/**
* Gets the ID of the last inserted row immediately after an INSERT
* statement. The returned value can be used for selecting the item that has
* just been inserted or for updating another table with an ID pointing to
* that item.
*
* @return string|false Auto-incremented value of the last inserted row
*/
public function sql_last_inserted_id();
/**
* Add to query count
*

View File

@ -318,7 +318,15 @@ class factory implements driver_interface
*/
public function sql_nextid()
{
return $this->get_driver()->sql_nextid();
return $this->get_driver()->sql_last_inserted_id();
}
/**
* {@inheritdoc}
*/
public function sql_last_inserted_id()
{
return $this->get_driver()->sql_last_inserted_id();
}
/**

View File

@ -269,9 +269,9 @@ class mssql_odbc extends \phpbb\db\driver\mssql_base
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
function sql_nextid()
public function sql_last_inserted_id()
{
$result_id = @odbc_exec($this->db_connect_id, 'SELECT @@IDENTITY');

View File

@ -271,9 +271,9 @@ class mssqlnative extends \phpbb\db\driver\mssql_base
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
function sql_nextid()
public function sql_last_inserted_id()
{
$result_id = @sqlsrv_query($this->db_connect_id, 'SELECT @@IDENTITY');

View File

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

View File

@ -570,9 +570,9 @@ class oracle extends \phpbb\db\driver\driver
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
function sql_nextid()
public function sql_last_inserted_id()
{
$query_id = $this->query_result;

View File

@ -342,9 +342,9 @@ class postgres extends \phpbb\db\driver\driver
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
function sql_nextid()
public function sql_last_inserted_id()
{
$query_id = $this->query_result;

View File

@ -242,9 +242,9 @@ class sqlite3 extends \phpbb\db\driver\driver
}
/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function sql_nextid()
public function sql_last_inserted_id()
{
return ($this->db_connect_id) ? $this->dbo->lastInsertRowID() : false;
}