db_last_insert_id
Definition
db_last_insert_id($table, $field)
includes/database.pgsql.inc, line 229
Description
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
| Name | Description |
|---|---|
| Database abstraction layer | Allow the use of different database servers using the same code base. |
Code
<?php
function db_last_insert_id($table, $field) {
return db_result(db_query("SELECT CURRVAL('{". db_escape_table($table) ."}_". db_escape_table($field) ."_seq')"));
}
?> 