db_next_id

Versions
4.6 – 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

▾ 14 functions call db_next_id()

aggregator_save_category in modules/aggregator.module
aggregator_save_feed in modules/aggregator.module
aggregator_save_item in modules/aggregator.module
comment_post in modules/comment.module
menu_edit_item_save in modules/menu.module
Save changes to a menu item into the database.
menu_rebuild in includes/menu.inc
Populate the database representation of the menu.
node_save in modules/node.module
Save a node object into the database.
taxonomy_save_term in modules/taxonomy.module
taxonomy_save_vocabulary in modules/taxonomy.module
update_83 in database/updates.inc
update_99 in database/updates.inc
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.

Code

includes/database.pgsql.inc, line 148

<?php
function db_next_id($name) {
  $id = db_result(db_query("SELECT nextval('%s_seq')", db_prefix_tables($name)));
  return $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.