Help with SQL query and associative array

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I am using a SQL query to pull data that I need for a report. I can get
it to print out just fine on screen, but I can't figure out how to get
the data into an associative array. I have been playing with this for
the past few days and cannot get over the hump on this one.

Can someone please help?

The reason i need to get this data into an associative array is because
the data represents a report I need to export into Excel via the
xlsStream class.

Any help would be much appreciated. I need to get this done for my boss


Re: Help with SQL query and associative array wrote:

Quoted text here. Click to load it

Which database do you use?

Or do you use an abstractionlayer maybe?

The right answer depends on your circumstances.
If you use ADODB, try:
$RS = $conn->Execute($someSQL)->getArray();
to make the $RS an assoc array.
(I always do this because it makes the use of the $RS so much more  

If you use ADODB be sure you set the connection-object first in assoc mode,  
with something like:

From Postgresql:
use pg_fetch_assoc()


So just look up the corresponding command for you database at

Erwin Moller

Site Timeline