I have a database running on PostgreSQL.
My script runs an SQL query and then retrieves the data with calls to
pg_fetch_array. It then stores each record for later use, looking it up in
memory.
What I have found is that pg_fetch_array is not reliable in terms of the key
name in the associative array. To test this I retrieved data using a call to
pg_fetch_array and then used the following code shown in the PHP help file
to print out the fields and their data:
while (list ($key, $val) = each ($row))
echo "$key => $val<br>";
This will return each field twice: once with a numeric key, and once with a
named key. However in some cases the named key does not return any data.
Here is an example:
0 => 27
scheduleid => 27
1 => M10V PMT
displaytext => M10V PMT
2 => Mitre 10 Visa Payment Due
descriptext =>
3 => https://sec.westpactrust.co.nz/servlet/Banking?xtr=Logon
url =>
4 => t
current => t
5 => f
reminder => f
6 =>
hideinsummary =>
7 => 35
occurrid => 35
8 => 27
9 => 26/12/2000
occurdate => 26/12/2000
10 => 00:00:00
starttime => 00:00:00
11 => 00:00:00
endtime => 00:00:00
12 => t
allday => t
13 => 3
importance => 3
14 =>
repeats =>
15 =>
16 =>
There are 17 fields in the result set (correct). You can see the problem
occurring in field 2 and 3. The numeric key returns values but the named key
doesn't. This doesn't occur on every single record, only on some records.
The other problem is that there is no named key for when the same field name
is returned a second time. Postgres names these fields the same except it
adds "_1" on the end of the name. But this is evidently left unresolved by
PHP. Fields 8, 15 and 16 are examples.
The only reliable way I can see of being able to retrieve the data is to use
numbered rather than fieldname references. It only seems to apply to a few
fields and is without logic, since in some cases it does dereference
correctly.
--
=======================================================================
Patrick Dunford, Christchurch, NZ - http://pdunford.godzone.net.nz/
Rejoice in the Lord always. I will say it again: Rejoice!
-- Philippians 4:4
http://www.heartlight.org/cgi-shl/todaysverse.cgi?day=20010404
=======================================================================
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]