这是我的代码
$sql1 = "SELECT * FROM user_follow WHERE user = :user";
$stmt1 = $conexao_pdo->prepare($sql1);
//where clause
$stmt1->bindParam(':user', $username);
$stmt1->execute();
while ($row1 = $stmt1->fetch(PDO::FETCH_ASSOC))
{
echo '</br>Followers: </br>'.$row1['followers'].'</br>';
}
它显示了关注者的名字,但我希望PDO中的实现也能显示$row1['followers']
答案 0 :(得分:1)
如果您只需要计数,可以使用rowCount()
功能:
$stmt1->execute();
$count = $stmt1->rowCount();
echo '</br>Followers: </br>'.$count.'</br>';
所以它只是回显$ count