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.

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

▾ 14 functions call db_next_id()

aggregator_save_category in modules/aggregator/aggregator.module
Add/edit/delete aggregator categories.
aggregator_save_feed in modules/aggregator/aggregator.module
Add/edit/delete an aggregator feed.
aggregator_save_item in modules/aggregator/aggregator.module
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
drupal_client_ping in modules/drupal/drupal.module
Callback function from drupal_xmlrpc() called when another site pings this one.
menu_save_item in modules/menu/menu.module
Save a menu item to the database.
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.
taxonomy_save_term in modules/taxonomy/taxonomy.module
Helper function for taxonomy_form_term_submit().
taxonomy_save_vocabulary in modules/taxonomy/taxonomy.module
upload_save in modules/upload/upload.module
user_save in modules/user/user.module
Save changes to a user account or add a new user.

Code

includes/database.pgsql.inc, line 235

<?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.