get last resource ID (postgres) question
| From: | Dynsolve | Date: | Tue, 19 Mar 2002 19:58:31 +0000 |
| Subject: | get last resource ID (postgres) question | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-89189@lists.php.net to get a copy of this message | ||
Hello, Its been a while since I have posted a question. Regards to all of you out
there supporting the best in the biz (php and the open source community).
I am wondering how to get the last resource ID from a call. I have a loop making
pg calls, the resource ID's vary of course. Looking for a dynamic work around,
otherwise a way to replace my print_r below with a line of code which grabs the
last resource ID. Please check out this code, open to any suggestions. This
code is abbreviated to ensure clarity:
<?
// made a call and got 3 rows using the results to further loop below
for($x=0;$x<$rows){
$AGARR=pg_fetch_array($result, $x);
$a=AGARR[0];
$b=$AGARR[1];
$c=$AGARR[2];
// here i open a new connection and expect 1 row for each iteration
$callTmb="select z from mytable where tempfu='$a'";
$Tmbconnect=pg_connect("$db_parms_client");
$resultTmb=pg_exec($Tmbconnect, $callTmb);
$Tmbrows=pg_numrows($resultTmb);
echo $callTmb . "!! $Tmbrows";
// THE ABOVE ECHO gives me the call and expected "1" as number found.
print_r($resultTmb);
// SOMETIMES a particular return is result #13, sometimes #15.
// THIS is used on various pages. I need to grab the last ID so that
// it can remain dynamic, or have it reset so that the resouce ID is
// always 0 for each iteration.
}
?>
Hope this makes some sense, more importantly, hope someone has a bone they
could throw me :) THanks a bunch,
Kristopher Spencer-Yates