Perhaps something like this?
$i = 0;
foreach($resultSet as $key => $value){
$output[$i++][$key] = $value;
}
Given a $resultSet
like this:
$resultSet['key0'] = 'value0';
$resultSet['key1'] = 'value1';
$resultSet['key2'] = 'value2';
$resultSet['key3'] = 'value3';
$resultSet['key4'] = 'value4';
$resultSet['key5'] = 'value5';
The above code will produce something as follows:
Array (
[0] => Array ( [key0] => value0 )
[1] => Array ( [key1] => value1 )
[2] => Array ( [key2] => value2 )
[3] => Array ( [key3] => value3 )
[4] => Array ( [key4] => value4 )
[5] => Array ( [key5] => value5 )
)
Echoing $output[0]['key0]
will output value0
(or an array if value0 is an array).
As a side note, you could actually get completely rid of $i, and just do the following:
foreach($resultSet as $key => $value){
$output[][$key] = $value;
}
Do let me know if I completely misunderstood the question at hand though :)
SELECT a as b
orSELECT a b
) and then usefetchAll()
. Not sure what other APIs have a method like that. – Corbin Jan 7 at 5:33