How can the rowCount method in PDO be utilized in PHP for database operations?

The `rowCount` method in PDO can be utilized in PHP for database operations to retrieve the number of rows affected by a SQL statement (such as SELECT, INSERT, UPDATE, DELETE). This can be useful for checking the success of an operation or for displaying the number of affected rows to the user.

// Assuming $pdo is your PDO connection object

$stmt = $pdo->prepare("SELECT * FROM users WHERE status = :status");
$stmt->execute(['status' => 'active']);

$rowCount = $stmt->rowCount();
echo "Number of active users: " . $rowCount;