db_next_id

  1. drupal
    1. 4.7 database.mysql.inc
    2. 4.7 database.mysqli.inc
    3. 4.7
    4. 5 database.mysqli.inc
    5. 5 database.mysql.inc
    6. 5
    7. 7 database.inc
Versions
4.7 – 5 db_next_id($name)
7 db_next_id($existing_id = 0)

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.

Related topics

▾ 15 functions call db_next_id()

aggregator_save_category in modules/aggregator.module
Add/edit/delete aggregator categories.
aggregator_save_feed in modules/aggregator.module
Add/edit/delete an aggregator feed.
aggregator_save_item in modules/aggregator.module
comment_save in modules/comment.module
Accepts a submission of new or changed comment content.
drupal_client_ping in modules/drupal.module
Callback function from drupal_xmlrpc() called when another site pings this one.
menu_save_item in modules/menu.module
Save a menu item to the database.
node_save in modules/node.module
Save a node object into the database.
system_update_146 in database/updates.inc
system_update_151 in database/updates.inc
system_update_159 in database/updates.inc
Retrieve data out of the old_revisions table and put into new revision system.
taxonomy_save_term in modules/taxonomy.module
taxonomy_save_vocabulary in modules/taxonomy.module
upload_save in modules/upload.module
user_admin_access_add in modules/user.module
Menu callback: add an access rule
user_save in modules/user.module
Save changes to a user account or add a new user.

Code

includes/database.pgsql.inc, line 200

<?php
function db_next_id($name) {
  $id = db_result(db_query("SELECT nextval('%s_seq')", db_prefix_tables($name)));
  return $id;
}
?>