Okay, I need to get the nextval('sequence')
What exact code do I have to run to get the next value of the sequence?
Thanks
Nextval()
Moderator: General Moderators
Re: Nextval()
What is "sequence"? We aren't psychic, if we need to know something then you need to tell us.
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Nextval()
Assuming you're trying to access a Postgres sequence:
Code: Select all
SELECT nextval('sequence');Re: Nextval()
I ran that, and it gives me the result as something in the form "ResourceID=#"
outputs:
it doesnt seem to output the actual value of the current value, which is an intiger. Am I using it wrong still?
Code: Select all
$result = pg_query("SELECT currval('".$table."_".$column."_seq')");
print_r($result);Code: Select all
Resource id #68- volomike
- Forum Regular
- Posts: 633
- Joined: Wed Jan 16, 2008 9:04 am
- Location: Myrtle Beach, South Carolina, USA
Re: Nextval()
Database resources don't play like that. You have to do it like this:
And if you want nextval instead of currval, do it like so:
Code: Select all
$rwRow = pg_fetch_array($result);
print_r($rwRow);
echo "<br />\n" . $rwRow['currval'];Code: Select all
$result = pg_query("SELECT nextval('".$table."_".$column."_seq')");
$rwRow = pg_fetch_array($result);
print_r($rwRow);
echo "<br />\n" . $rwRow['nextval'];Re: Nextval()
Thank you, I was missing pg_fetch_array.