views:

46

answers:

1

I am doing a query which fetches two fields.
I need each of those fields into a different array.
Will this rerun the query for each call or just re iterate over the result set?

$a= Laststatment->fetchAll(PDO::FETCH_COLUMN,0);
$b= Laststatment->fetchAll(PDO::FETCH_COLUMN,1);
A: 

Option 3: it will NOT reiterate over the resultset at all, as everything already has been fetched, and the second call will return an empty array (at least, here it does).

 $a = array();
 $b = array();
 while($r = $laststatement->fetch(PDO::FETCH_NUM)){
    $a[] = $r[0];
    $b[] = $r[1];
 }

That is: with MySQL there is no scrollable cursor, I have not attempted other database with a PDO::CURSOR_SCROLL possibility.

Wrikken