note 16826 added to function.pg-getlastoid
| From: | kyle at kyletyoung dot com | Date: | Thu, 15 Nov 2001 01:12:29 +0000 |
| Subject: | note 16826 added to function.pg-getlastoid | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-20851@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);
--
http://www.php.net/manual/en/function.pg-getlastoid.php
http://master.php.net/manage/user-notes.php?action=edit+16826
http://master.php.net/manage/user-notes.php?action=delete+16826
http://master.php.net/manage/user-notes.php?action=reject+16826