Austin Austin - 3 months ago 4
MySQL Question

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

Basically I am not exactly sure how to fetch the query in order to be able to count the number of rows.

I need the get the number of rows for the purpose of a checker.

Code below:

$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);

some how right here fetch in a way that lets me count the number of rows

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


PDOStatement object provides a rowCount() method, which returns the number of rows 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.