On Thu, 2004-10-28 at 16:51 -0600, Ed L. wrote: > On Thursday October 28 2004 11:42, Robby Russell wrote: > > > > Thanks, this seems to work well. My goal is to actually create a php > > function that takes a result and returns the insert_id like > > mysql_insert_id() does, but without needing to know the sequence names > > and such. I would make a psql function, but I don't always have that > > option with some clients existing systems. > > An alternative is to simply select nextval() from a separately-created > sequence object to get the serial value, then insert with that value. No > need to have a serial column then, but you do need to explicitly create the > sequence object, as opposed to SERIAL. >
nextval, currval, either way, I would need to know the specific sequence name. Was looking for a good way to pass a function a schema and table and return a sequence. I got exactly what I was looking for and have been able to build a function that will handle this for me. It's part of a db layer class that I use with mysql and pgsql, and was using mysql_insert_id and wanted to model a function that would return an id like the mysql_insert_id function does. (one of the few pgsql/php functions that doesn't exist in php natively..but does with mysql) -Robby -- /*************************************** * Robby Russell | Owner.Developer.Geek * PLANET ARGON | www.planetargon.com * Portland, OR | [EMAIL PROTECTED] * 503.351.4730 | blog.planetargon.com * PHP/PostgreSQL Hosting & Development * --- Now supporting PHP5 --- ****************************************/
signature.asc
Description: This is a digitally signed message part