爲了從數據庫中獲取的結果,你可以這樣做: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