CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Advanced:
perl/dbi

 



parham_m_s
journeyman

Jun 28, 2001, 8:19 AM

Post #1 of 3 (1173 views)
perl/dbi Can't Post

i've selected, prepared, and executed my mysql statement... now what i want to do is push everything into an array because i don't want to drastically change my code from what it used to be, deliminated with pipes.

i came up with this code (which is kinda what i want):


Code
$data = $sth->fetchall_arrayref; #grabs all the data and puts it into an array 
foreach $row (@$data){
#now how do i split $row into each column?? this is what i theoretically think will work...
($id,$name,$explain,$question,$yes,$no) = $row->fetchrow()
}

are my handles right?, is there a different way i should be splitting my rows? I kinda haven't solved the problem, what i want to do is push each row into an array with columns separated with |'s (pipes)... any help?



mhx
Enthusiast

Jun 28, 2001, 8:46 AM

Post #2 of 3 (1171 views)
Re: perl/dbi [In reply to] Can't Post

Hi,

here's just a guess. I cannot verify it, because I don't have the DBI stuff installed. And I don't know exactly what you're trying to do from what you say. So please don't mind if I got you wrong.
As far as I know about the fetchall_arrayref method, it returns a reference to an array of array references, which makes the $row->fetchrow() unneccessary. I guess you want to assign an array to your variables. Since $row is a reference to an array containing all elements in the current row, you can write

Code
($id,$name,$explain,$question,$yes,$no) = @$row;

I hope this will at least point you into the right direction.

-- Marcus



parham_m_s
journeyman

Jun 28, 2001, 8:55 AM

Post #3 of 3 (1170 views)
Re: perl/dbi [In reply to] Can't Post

actually that did answer my question.. thank you mhx :).


 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives