Re: postgres version mysql_insert_id
| From: | Doug Semig | Date: | Tue, 18 Jul 2000 08:27:55 +0000 |
| Subject: | Re: postgres version mysql_insert_id | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-7044@lists.php.net to get a copy of this message | ||
You have to do it in a couple of steps to emulate the MySQL equivalent.
/* Untested code...written off the top of my head */
$pgoid=pg_GetLastOID();
$result=pg_exec($conn, "SELECT id FROM table WHERE oid=$pgoid");
$data=pg_fetch_row($result, 0);
echo $data[0]; /* or whatever you want to do with the id */
In the above snippet, of course, you'd adjust your SQL statement ("id"
would be the name of whatever field you use for your primary key and
"table" would be your table name) and reuse your already opened connection.
Doug
At 11:03 PM 7/17/00 -0700, Keith Vance wrote:
>Is there a function in PHP for getting the last insert id using
>Postgresql? pg_GetLastOid doesn't do what I thought it would.
>
>Thanks,
>Keith