| Versions | |
|---|---|
| 4.7 – 5 | db_next_id( |
| 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. Using a serial field is preferred, and InsertQuery::execute() returns the value of the last ID inserted.
$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.
An integer number larger than any number returned before for this sequence.
drupal/
<?php
function db_next_id($existing_id = 0) {
return Database::getConnection()->nextId($existing_id);
}
?>