?
Solved

Retrieving data from the database

Posted on 1999-11-11
4
Medium Priority
?
149 Views
Last Modified: 2010-03-05
I have a select statement as follows :
select * from table
how do i store all the fields into variables? previously i only retrieve 1 field .. so i had no problems

"select fieldA from table"
while ($query->FetchRow()) {
      $result = $query->Data();
}

if i have more than 1 field, how do i store all the fields into variables?
0
Comment
Question by:irene79
  • 2
  • 2
4 Comments
 
LVL 2

Expert Comment

by:mattrope
ID: 2202204
Have you tried replacing $result with an array such as @result or with a list such as ($field1, $field2, $field3)?  
0
 

Author Comment

by:irene79
ID: 2202215
no i did not .. i'm very new to perl, so i do not know the syntax. How do i write the actual code? Please advice. Thanks!
0
 
LVL 2

Accepted Solution

by:
mattrope earned 30 total points
ID: 2202225
Instead of

$result = $query->Data();

try

@results = $query->Data();

to put the fields into an array called @results or try

($field1,$field2,$field3) = $query->Data();

to put the field values into variables called $field1, $field2, $field3, etc.  I'm not sure what database access module you are using, but this is how some of them work...

0
 

Author Comment

by:irene79
ID: 2202338
Thanks mattrope :)
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans
Suggested Courses

607 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question