为了从数据库中获取的结果,你可以这样做:fetchAll的要点是什么?
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$sth->execute();
$result = $sth->fetchAll();
foreach($result as $r) {
echo "<pre>";
print_r($r);
echo "</pre>";
}
,但它似乎没有使用fetchAll
工作,例如:
$sth = $dbh->prepare("SELECT name, colour FROM fruit");
$result = $sth->execute();
foreach($result as $r) {
echo "<pre>";
print_r($r);
echo "</pre>";
}
这样的区别是什么?
这很奇怪,因为执行返回TRUE或FALSE。 http://www.php.net/manual/en/pdostatement.execute.php – malletjo 2012-02-18 01:58:38
其实@racar – 2012-02-18 02:07:31