Same name in this branch
- 6.x includes/database.pgsql.inc \db_last_insert_id()
- 6.x includes/database.mysql-common.inc \db_last_insert_id()
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
5 calls to db_last_insert_id()
- batch_process in includes/
form.inc - Processes the batch.
- block_add_block_form_submit in modules/
block/ block.admin.inc - Save the new custom block.
- 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.
- system_install in modules/
system/ system.install - Implementation of hook_install().
File
- includes/
database.pgsql.inc, line 230 - Database interface code for PostgreSQL database servers.
Code
function db_last_insert_id($table, $field) {
return db_result(db_query("SELECT CURRVAL('{" . db_escape_table($table) . "}_" . db_escape_table($field) . "_seq')"));
}