What potential pitfalls should be considered when transitioning from using arrays to database queries in PHP for a webshop?

One potential pitfall to consider when transitioning from using arrays to database queries in PHP for a webshop is the risk of SQL injection attacks if user input is not properly sanitized. To mitigate this risk, always use prepared statements or parameterized queries to prevent malicious SQL code from being injected into your queries.

// Example of using prepared statements to prevent SQL injection
$stmt = $pdo->prepare("SELECT * FROM products WHERE category = :category");
$stmt->bindParam(':category', $category);
$stmt->execute();
$results = $stmt->fetchAll();