db_last_insert_id

Versions
6
db_last_insert_id($table, $field)

Returns the last insert id. This function is thread safe.

Parameters

$table The name of the table you inserted into.

$field The name of the autoincrement field.

Related topics

▾ 10 functions call db_last_insert_id()

actions_save in includes/actions.inc
Save an action and its associated user-supplied parameter values to the database.
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
Add/edit/delete an aggregator item.
batch_process in includes/form.inc
Process the batch.
block_add_block_form_submit in modules/block/block.admin.inc
Save the new custom block.
comment_save in modules/comment/comment.module
Accepts a submission of new or changed comment content.
drupal_write_record in includes/common.inc
Save a record to the database based upon the schema.
menu_link_save in includes/menu.inc
Save a menu link.
user_save in modules/user/user.module
Save changes to a user account or add a new user.

Code

includes/database.pgsql.inc, line 230

<?php
function db_last_insert_id($table, $field) {
  return db_result(db_query("SELECT CURRVAL('{". db_escape_table($table) ."}_". db_escape_table($field) ."_seq')"));
}
?>
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.