【发布时间】:2025-12-31 14:30:12
【问题描述】:
如何使用 PDO 返回计数的行数?
这是我的代码:
$n=$dbh->prepare("SELECT count(*) FROM users_notifications WHERE userid=0 OR userid=:userid");
$n->bindParam(":userid",$userdata['id']);
$n->execute();
$notifications = count($n);
这仅返回 1。虽然我在数据库中运行查询时有 2 个结果:SELECT count(*) FROM users_notifications WHERE userid=0 OR userid=:userid
【问题讨论】: