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.

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.

... See full list

File

drupal-6.x/includes/database.mysql-common.inc, line 540
Functions shared between mysql and mysqli database engines.

Code

function db_last_insert_id($table, $field) {
  return db_result(db_query('SELECT LAST_INSERT_ID()'));
}