我如何需要 return 查询才能计算行数,我该如何计算行数?

How do I need to return the query in order to count the number of rows, and how do I count the rows?

基本上我不太确定如何获取查询以便能够计算行数。

我需要获取行数以进行检查。

代码如下:

$query = $handler->prepare("SELECT * FROM Admins WHERE ID= :userID OR Username= :userName OR Password= :encPass");
$query->bindParam(':userID', $userID);
$query->bindParam(':userName', $userName);
$query->bindParam(':encPass', $encrypted_password);
$query->execute();

这里是如何以一种让我计算行数的方式获取的

if (number of rows from query is >=1){

PDOStatement对象提供了rowCount()方法,其中returns行数SELECTed:

If the last SQL statement executed by the associated PDOStatement was a SELECT statement, some databases may return the number of rows returned by that statement. However, this behaviour is not guaranteed for all databases and should not be relied on for portable applications.