Reputation: 2035
I'm using PDO's FETCH_ASSOC to get data from a database. Unfortunately, it creates a new array for every row.
Array (
key => value
)
Array (
key2 => value2
)
Is there a way to separate the arrays? I want to create an array of arrays, but I know how to do that if I will be able to separate the arrays.
$q = $DBH->query($sql) or die("failed!");
$q->setFetchMode(PDO::FETCH_ASSOC);
while($r = $q->fetch()){
print_r($r);
}
EDIT:
This is what I wan't the big array to look like:
Array( [0] => Array(...), [1] => Array(...) ... [n] => Array(...) )
Upvotes: 1
Views: 114
Reputation: 595
did mean something like this?
edit:
$result = $q->fetchAll();
print_r($result);
from: http://www.php.net/manual/en/pdostatement.fetchall.php
Upvotes: 1