<?php
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();
/* Fetch all of the remaining rows in the result set */
print("Fetch all of the remaining rows in the result set:\n");
$result = $sth->fetchAll();
print_r($result);
?>
The above example will fetch all of the remaining rows in the result set and output something similar to:
Array
(
    [0] => Array
        (
            [NAME] => pear
            [0] => pear
            [COLOUR] => green
            [1] => green
        )
    [1] => Array
        (
            [NAME] => watermelon
            [0] => watermelon
            [COLOUR] => pink
            [1] => pink
        )
)
Is there any option to get a result like the one my_sql_fetch_array returns, which looks like this:
Array
(
    [0] => Array
        (
            [0] => pear
            [1] => green
        )
    [1] => Array
        (
            [0] => watermelon             
            [1] => pink
        )
)
                From http://php.net/manual/en/pdostatement.fetch.php
$result = $sth->fetchAll(PDO::FETCH_NUM);
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With