当数据库中实际有两列符合这些条件时,为什么fetchColumn()
会返回“1”?
如果数据库中有1条记录匹配则返回false?
(我曾经做过完美的$num_of_rows = $stmt->num_rows()
)
$follower = 1;
$following = 1;
$stmt = $dbCon->prepare(" SELECT login_followers_status "
. " FROM login_followers "
. " WHERE login_followers_follower = ? "
. " AND login_followers_following = ? ");
$stmt->bindParam(1, $follower);
$stmt->bindParam(2, $following);
$stmt->execute();
$row = $stmt->fetch();
$status = $row['login_followers_status'];
$num_of_rows = $stmt->fetchColumn();
echo $num_of_rows;
答案 0 :(得分:0)
为什么不阅读说明书?
public mixed PDOStatement::fetchColumn ([ int $column_number = 0 ] )
PDOStatement :: fetchColumn - 返回下一行的单个列 结果集。
从结果集的下一行返回单个列,如果是,则返回FALSE 没有更多的行。
警告如果是,则无法从同一行返回另一列 您使用PDOStatement :: fetchColumn()来检索数据。