note 31570 added to function.pg-last-oid

From: Date: Sat, 26 Apr 2003 12:15:40 +0000
Subject: note 31570 added to function.pg-last-oid
Groups: php.notes 
Request: Send a blank email to php-notes+get-47135@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_for_id); if(pg_num_rows($result_for_id)) $id=pg_fetch_array($result_for_id,0,PGSQL_ASSOC); return $id[$column_name]; } Call after insert, simply ;) -- http://www.php.net/manual/en/function.pg-last-oid.php http://master.php.net/manage/user-notes.php?action=edit+31570 http://master.php.net/manage/user-notes.php?action=delete+31570 http://master.php.net/manage/user-notes.php?action=reject+31570

« previous php.notes (#47135) next »