What are some best practices for structuring and organizing PDO queries in PHP to avoid empty result arrays?

When querying a database using PDO in PHP, it's important to handle empty result arrays gracefully to avoid errors in your application. One way to do this is by checking if the result array is empty before trying to access its elements. This can be done using the `rowCount()` method to determine if any rows were returned by the query.

// Example of structuring and organizing PDO queries to avoid empty result arrays
$stmt = $pdo->prepare("SELECT * FROM table WHERE column = :value");
$stmt->execute(['value' => $someValue]);

if ($stmt->rowCount() > 0) {
    $results = $stmt->fetchAll(PDO::FETCH_ASSOC);
    // Process the results here
} else {
    // Handle case where no results were found
}