function db_last_insert_id
6.x database.pgsql.inc | db_last_insert_id($table, $field) |
6.x database.mysql-common.inc | 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
11 calls to db_last_insert_id()
- actions_save in drupal-6.x/
includes/ actions.inc - Save an action and its associated user-supplied parameter values to the database.
- aggregator_save_category in drupal-6.x/
modules/ aggregator/ aggregator.module - Add/edit/delete aggregator categories.
- aggregator_save_feed in drupal-6.x/
modules/ aggregator/ aggregator.module - Add/edit/delete an aggregator feed.
- aggregator_save_item in drupal-6.x/
modules/ aggregator/ aggregator.module - Add/edit/delete an aggregator item.
- batch_process in drupal-6.x/
includes/ form.inc - Processes the batch.
File
- drupal-6.x/
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')"));
}