I wrote in another thread about having problems when storing data from a 
pgsql query into associative arrays using pg_fetch_array.

In order to further test this behaviour I wrote my own pgFetchArray function 
to work basically the same way. This is the code:

        function pgFetchArray($rsid,$rownum)
        {
                $fldcount = pg_numfields($rsid);
                for ($fld=0;$fld<$fldcount;$fld++)
                {
                        $fldname = pg_fieldname($rsid,$fld);
                        $flddata = pg_result($rsid,$rownum,$fld);
                        echo "row=$rownum fld=$fld fldname=$fldname 
value=$flddata<BR>";
                        $dArray[$fldname] = $flddata;
                        $dArray[$fld] = $flddata;
                }
                while (list ($key, $val) = each ($dArray)) 
                        echo "$key=$val ";
                echo "<BR>";
                return $dArray;
        }

Here is one record from the query:

row=0 fld=0 fldname=scheduleid value=27
row=0 fld=1 fldname=displaytext value=M10V PMT
row=0 fld=2 fldname=descriptext value=Mitre 10 Visa Payment Due
row=0 fld=3 fldname=url 
value=https://sec.westpactrust.co.nz/servlet/Banking?xtr=Logon
row=0 fld=4 fldname=current value=t
row=0 fld=5 fldname=reminder value=f
row=0 fld=6 fldname=hideinsummary value=
row=0 fld=7 fldname=occurrid value=35
row=0 fld=8 fldname=scheduleid value=27
row=0 fld=9 fldname=occurdate value=26/12/2000
row=0 fld=10 fldname=starttime value=00:00:00
row=0 fld=11 fldname=endtime value=00:00:00
row=0 fld=12 fldname=allday value=t
row=0 fld=13 fldname=importance value=3
row=0 fld=14 fldname=repeats value=
row=0 fld=15 fldname=descriptext value=
row=0 fld=16 fldname=url value=
scheduleid=27 0=27 displaytext=M10V PMT 1=M10V PMT descriptext= 2=Mitre 10 
Visa Payment Due url= 
3=https://sec.westpactrust.co.nz/servlet/Banking?xtr=Logon current=t 4=t 
reminder=f 5=f hideinsummary= 6= occurrid=35 7=35 8=27 occurdate=26/12/2000 
9=26/12/2000 starttime=00:00:00 10=00:00:00 endtime=00:00:00 11=00:00:00 
allday=t 12=t importance=3 13=3 repeats= 14= 15= 16= 

The interesting point is that fields 15 and 16 are given names by Postgres 
that include underscores (because the same field name occurs in both tables 
of the query). Yet when PHP gets the field names the _1 etc have been 
removed. Perhaps there is a problem with confusion of the names of the 
fields. I will try rewriting my query.

-- 
=======================================================================
Patrick Dunford, Christchurch, NZ - http://pdunford.godzone.net.nz/

   Do not be anxious about anything, but in everything, by prayer
and petition, with thanksgiving, present your requests to God.
    -- Philippians 4:6
http://www.heartlight.org/cgi-shl/todaysverse.cgi?day=20010406
=======================================================================
Created by Mail2Sig - http://pdunford.godzone.net.nz/software/mail2sig/

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to