pg.ddx.io pgsql-php@postgresql.org mailing list archive
help / color / mirror / Atom feedNextval again
2+ messages / 2 participants
[nested] [flat]
* Nextval again
@ 2001-10-13 04:51 Zavier Sheran <zsheran@yahoo.com>
2001-10-13 13:11 ` Re: Nextval again Papp Gyozo <pgerzson@freestart.hu>
0 siblings, 1 reply; 2+ messages in thread
From: Zavier Sheran @ 2001-10-13 04:51 UTC (permalink / raw)
To: pgsql-php
Thanks for the help I received.
I did run different queries like
$number = pg_Exec ($db_connect, "SELECT
nextval('members_recordid_seq')");
$number = pg_Exec ($db_connect, "SELECT last_value
FROM members_recordid_seq");
What I get when I "echo $number;" is "Resource id #2",
no matter what number the sequence is at (currently
19).
If I run the same queries in phpPgAdmin I get the
correct results.
I run PHP 4.04 and PgSQL 7.03
Any ideas?
__________________________________________________
Do You Yahoo!?
Make a great connection at Yahoo! Personals.
http://personals.yahoo.com
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Nextval again
2001-10-13 04:51 Nextval again Zavier Sheran <zsheran@yahoo.com>
@ 2001-10-13 13:11 ` Papp Gyozo <pgerzson@freestart.hu>
0 siblings, 0 replies; 2+ messages in thread
From: Papp Gyozo @ 2001-10-13 13:11 UTC (permalink / raw)
To: Zavier Sheran <zsheran@yahoo.com>; pgsql-php
Hello,
> I did run different queries like
No matter what queries are executed as long as they are valid. :)
>
> $number = pg_Exec ($db_connect, "SELECT
> nextval('members_recordid_seq')");
>
> $number = pg_Exec ($db_connect, "SELECT last_value
> FROM members_recordid_seq");
>
> What I get when I "echo $number;" is "Resource id #2",
> no matter what number the sequence is at (currently
> 19).
Yes, because as the PHP manual says:
pg_Exec() returns a valid resource id on success, or FALSE on failure.
It means that you have to fetch the rows from the result set pointed by
this resource id. To describe it very loosely, the resource id only points
to a memory location where the rows returned by a SELECT statement are
stored.
So you must :
$result = pg_exec($db_connnect, "SELECT -- your query goes here...;");
for ($row = 0; $row < pg_numrows($result); $row++)
{
$record = pg_fetch_row($result, $row);
print_r($record);
}
//if you are interested only a specific row (ie.: thwe 1st one, like above)
$result = pg_Exec ($db_connect, "SELECT nextval('members_recordid_seq')");
list($number) = pg_fetch_row($result, 0); // row numbering starts from 0.
>
> If I run the same queries in phpPgAdmin I get the
> correct results.
phpPgAdmin does this fetching automatically.
> I run PHP 4.04 and PgSQL 7.03
You are strongly encouraged to upgrade both.
> Any ideas?
>
> __________________________________________________
> Do You Yahoo!?
> Make a great connection at Yahoo! Personals.
> http://personals.yahoo.com
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/users-lounge/docs/faq.html
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2001-10-13 13:11 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-10-13 04:51 Nextval again Zavier Sheran <zsheran@yahoo.com>
2001-10-13 13:11 ` Papp Gyozo <pgerzson@freestart.hu>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox