I would strongly recommend

  1) perldoc DBI   # to read the excellent DBI documentation
                     included with the DBI module
  2) "Programming the Perl DBI" book by Tim Bunce

"perldoc DBI" has a whole section on "fetchall_arrayref" - it
explains that fetchall_arrayref the way you've coded it I think
returns a reference to an array - each element of that array
is a "reference to an array" for one row returned from your query.

-------------------------------------------

my $all_rows_arrayref=$sth->fetchall_arrayref();

foreach $one_row_arrayref (@{$all_rows_arrayref}) {
   ($filename, $size, $score) = @{$one_row_arrayref};

   ### Now do whatever you want with $filename, $size, $score
}

--------------------------------------------

Be careful - this code is completely untested - it's been
a while since I've done DBI code, but hopefully it's close.

ALSO, be sure to read about "placeholders" in

    perldoc DBI

"placeholders" will save you a LOT of time and aggrevation with
proper quoting issues - and they can(will) also be a big help with
performance.

HTH.

-- 
Hardy Merrill
Senior Software Engineer
Red Hat, Inc.
[EMAIL PROTECTED]

Brad [[EMAIL PROTECTED]] wrote:
> I've been struggling with this and getting nothing but gibberish.
> 
> my $array_ref=$sth->fetchall_arrayref()
> 
> I can't get anything out of $array_ref though, I can't work out how to
> manipulate it.
> 
> The query was "select filename, size, score from files where
> codeID=\"".$codeID."\" which should return about 3-100 rows of data
> depending on the codeID, I then want to put into @filearray, @sizearray,
> @scorearray.  So far I've only managed to pull what looks like hex.
> 
> Any help GREATLY appreciated. I'm using mysql, on RH 6.2
> 

Reply via email to