rowCount() 方法試過好像沒用;下面這個方法也沒用$sql = "SELECT COUNT(*) FROM folks";if ($STH = $DBH->query($sql)) { # check the row count if ($STH->fetchColumn() > 0) { # issue a real select here, because there's data! } else { echo "No rows matched the query."; }}
3 回答

楊魅力
TA貢獻1811條經(jīng)驗 獲得超6個贊
$sql = "select * from folks";
$rs = $pdo->prepare($sql);
//$rs->exec();
$rs->execute();
$num = $rs->rowCount();
if($num){
#
}else{
#
}

慕無忌1623718
TA貢獻1744條經(jīng)驗 獲得超4個贊
$sql = "select count(*) from folks";
$rs = $pdo->prepare($sql);
$rs->execute();
$num = $rs->fetchColumn();
echo $num;
添加回答
舉報
0/150
提交
取消