Is there a more efficient way to check for empty results in PHP when fetching data from a database?

When fetching data from a database in PHP, you can check for empty results by using the `rowCount()` method of the PDOStatement object returned by the query. This method returns the number of rows affected by the last query, so if it returns 0, it means there are no results. This is a more efficient way to check for empty results compared to fetching the data and then checking if it's empty.

// Execute the query
$stmt = $pdo->query("SELECT * FROM table_name WHERE condition");

// Check if there are any results
if ($stmt->rowCount() > 0) {
    // Fetch the data
    $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
    // Process the results
} else {
    // Handle case where there are no results
}