note 31569 deleted from function.pg-last-oid by rioter
| From: | rioter@php.net | Date: | Sat, 26 Apr 2003 12:40:47 +0000 |
| Subject: | note 31569 deleted from function.pg-last-oid by rioter | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-47136@lists.php.net to get a copy of this message | ||
This is very useful function :)
function sql_last_inserted_id($connection, $result, $table_name, $column_name) {
$oid = pg_last_oid ( $result);
$query_for_id = "SELECT $column_name FROM $table_name WHERE oid=$oid";
$result_for_id = pg_query($connection,$query);
if(pg_num_rows($result_for_id))
$id=pg_fetch_array($result,0,PGSQL_ASSOC);
return $id[$column_name];
}
Call after insert, simply