What are the benefits and drawbacks of different approaches to constructing SQL queries in PHP, such as using concatenation versus complex syntax?

When constructing SQL queries in PHP, using concatenation can make the code more readable and maintainable for simple queries. However, for more complex queries or when dealing with user input, it is recommended to use prepared statements to prevent SQL injection attacks and improve performance.

// Using concatenation for simple query
$name = "John";
$query = "SELECT * FROM users WHERE name = '" . $name . "'";

// Using prepared statement for complex query
$name = "John";
$stmt = $pdo->prepare("SELECT * FROM users WHERE name = ?");
$stmt->execute([$name]);
$results = $stmt->fetchAll();