What are best practices for structuring and formatting SQL queries in PHP to avoid errors and improve readability?

When writing SQL queries in PHP, it's important to properly structure and format them to avoid errors and improve readability. One best practice is to use prepared statements to prevent SQL injection attacks and ensure proper escaping of user input. Additionally, breaking long queries into multiple lines and using indentation can make the code easier to read and maintain.

// Example of structuring and formatting a SQL query in PHP
$query = "SELECT column1, column2
          FROM table
          WHERE condition = :value";

$stmt = $pdo->prepare($query);
$stmt->bindParam(':value', $value);
$stmt->execute();