On Thu, 7 Jun 2001, Pete Emerson wrote:
> 1. $prep_query="SELECT school_name,path from student_data where 
>student_id=$student_id";
> 2. $query=$dbh->prepare($prep_query);
> 3. $query->execute;
> 4. $temp=$query->fetchall_arrayref();
> 5. foreach my $row (@$temp) {
> 6.  ($school,$path)=@$row;
> 7. # Do stuff with each $school, $path here
> 8. }
>
> 1. Is there a nice way to combine lines 1-3 or 1-4 into one nice easy
> statement?

You can combine 1-4 with...

$dbh->selectall_arrayref("SELECT school_name,path from...");

> 2. Is line 4 fetchall_arrayref returning a pointer $temp which points to
> the beginning of an array?

Line 4 is returning an array of arrays.  It is an array of references to
other arrays.

> 4. Is line five treating $row as a pointer to an array?

Correct.  Since $temp is an array of array references, foreach returns
an array reference on each iteration.

--
Ian

Reply via email to