Same name in this branch
- 5.x includes/database.pgsql.inc \db_next_id()
- 5.x includes/database.mysqli.inc \db_next_id()
- 5.x includes/database.mysql.inc \db_next_id()
Same name and namespace in other branches
- 4.6.x includes/database.pgsql.inc \db_next_id()
- 4.6.x includes/database.mysql.inc \db_next_id()
- 4.7.x includes/database.pgsql.inc \db_next_id()
- 4.7.x includes/database.mysqli.inc \db_next_id()
- 4.7.x includes/database.mysql.inc \db_next_id()
- 7.x includes/database/database.inc \db_next_id()
- 8.9.x core/includes/database.inc \db_next_id()
Return a new unique ID in the given sequence.
For compatibility reasons, Drupal does not use auto-numbered fields in its database tables. Instead, this function is used to return a new unique ID of the type requested. If necessary, a new sequence with the given name will be created.
Note that the table name should be in curly brackets to preserve compatibility with table prefixes. For example, db_next_id('{node}_nid');
Related topics
4 calls to db_next_id()
- node_save in modules/
node/ node.module - Save a node object into the database.
- system_update_146 in modules/
system/ system.install - system_update_151 in modules/
system/ system.install - system_update_159 in modules/
system/ system.install - Retrieve data out of the old_revisions table and put into new revision system.
File
- includes/
database.pgsql.inc, line 235 - Database interface code for PostgreSQL database servers.
Code
function db_next_id($name) {
$id = db_result(db_query("SELECT nextval('%s_seq')", db_prefix_tables($name)));
return $id;
}