You are here: Re: Help with SQL query and associative array « PHP Programming Language « IT news, forums, messages
Re: Help with SQL query and associative array

Posted by Erwin Moller on 04/10/06 11:57

geoffcastro@gmail.com wrote:

> 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
> ASAP.
>
> Thanks.

Which database do you use?

Or do you use an abstractionlayer maybe?

The right answer depends on your circumstances.
eg:
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
intuitive.)

If you use ADODB be sure you set the connection-object first in assoc mode,
with something like:
$conn->SetFetchMode(ADODB_FETCH_ASSOC);


From Postgresql:
use pg_fetch_assoc()

etc.

So just look up the corresponding command for you database at www.php.net.

Regards,
Erwin Moller

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация