-1

So ok before you start talking about that I should have looked it up and stuff, I did but found nothing that matches my needs exactly,so lets see;

Here is a sample from php.net describing how is it possible to fetch all results at once(click link),

look at Example #1 and tell me please how do I modify the given code to receive this result instead:

Array
(
[0] => Array
    (
        [0] => pear
        [1] => green
    )

[1] => Array
    (
        [0] => watermelon
        [1] => pink
    )

)

sorry for inconvenience and not using code spans,I just don't know how to do it :).

4

2 回答 2

2

in the given example, you need to change the line

$result = $sth->fetchAll(); to

$result = $sth->fetch(PDO::FETCH_NUM);

Here's the manual for PDO::fetch.

于 2012-10-02T18:17:58.637 回答
0

You need to use below to get index array result

$result = $sth->fetchAll(PDO::FETCH_NUM);
于 2012-10-02T18:13:05.517 回答