db_next_id

Versions
4.6 – 5
db_next_id($name)
7
db_next_id($existing_id = 0)

Retrieves a unique id.

Use this function if for some reason you can't use a serial field, normally a serial field with db_last_insert_id is preferred.

Parameters

$existing_id After a database import, it might be that the sequences table is behind, so by passing in a minimum id, it can be assured that we never issue the same id.

Return value

An integer number larger than any number returned before for this sequence.

Related topics

▾ 2 functions call db_next_id()

actions_save in includes/actions.inc
Saves an action and its user-supplied parameter values to the database.
user_save in modules/user/user.module
Save changes to a user account or add a new user.

Code

includes/database/database.inc, line 2274

<?php
function db_next_id($existing_id = 0) {
  return Database::getConnection()->nextId($existing_id);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.