<?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);
?>
上面的示例将获取结果集中所有剩余的行并输出类似于:
Array
(
[0] => Array
(
[NAME] => pear
[0] => pear
[COLOUR] => green
[1] => green
)
[1] => Array
(
[NAME] => watermelon
[0] => watermelon
[COLOUR] => pink
[1] => pink
)
)
是否有任何选项可以得到类似my_sql_fetch_array
返回的结果,如下所示:
Array
(
[0] => Array
(
[0] => pear
[1] => green
)
[1] => Array
(
[0] => watermelon
[1] => pink
)
)