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条经验 获得超6个赞
$sql = "select * from folks";
$rs = $pdo->prepare($sql);
//$rs->exec();
$rs->execute();
$num = $rs->rowCount();
if($num){
#
}else{
#
}
慕无忌1623718
TA贡献1744条经验 获得超4个赞
$sql = "select count(*) from folks";
$rs = $pdo->prepare($sql);
$rs->execute();
$num = $rs->fetchColumn();
echo $num;
添加回答
举报
0/150
提交
取消