note 16826 deleted from function.pg-getlastoid by jimw

From: Date: Fri, 07 Dec 2001 21:33:16 +0000
Subject: note 16826 deleted from function.pg-getlastoid by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22029@lists.php.net to get a copy of this message
This does what mysql_insert_id() does. Modified version of the above. function getinsertid($table, $col, $res) { $oid = pg_getlastoid($res); $r = @pg_exec($GLOBALS["conn"], "SELECT ".$col." from $table WHERE oid = $oid"); $row = pg_fetch_array($r, 0); return $row[$col]; } $res = pg_exec($conn, "INSERT INTO table (field1, field2) VALUES ('one', 'two')"); $id = getinsertid("table", "id", $res);

« previous php.notes (#22029) next »