getting serial in PHP

From: Date: Fri, 28 Mar 2003 12:46:36 +0000
Subject: getting serial in PHP
Groups: php.db 
Request: Send a blank email to php-db+get-26670@lists.php.net to get a copy of this message
Hi list. I have no real education in PHP or postgre, so forgive me if I dont use the correct language or expressions. I have a small problem that is probably easily solved if you just know how to do it. I have a PHP interface over a postgreSQL database, where I can search, add, delete or modify records. Now, when adding a new record, a query could look something like this: $query = "insert into logs values (nextval('public.logs_log_id_seq'::text),$id,'$logtext','now','$_SERVER[PHP_AUTH_USER]');"; The first value, the "nextval" thingie (if someone could give me the correct term for such a feature I would appriciate it) gives the added row a unique serial number. How do I figure out the serial my newly added row was assigned? What I want to do is something like 'echo "Your submission was accepted and assigned log ID $log_id"; ' directly below the $query line. How do I get the correct value into $log_id? Hopefully, someone understands my confused rantings and can give me directions to some documentation or maybe even the name of a variable I can use. :) TIA -- R

« previous php.db (#26670) next »