PDO更新查询集JSON字符串[重复]

This question already has an answer here:

can i update table and set JSON string with PDO? Because PDO is removing "\" character and diacritics is not working please help.

->query("UPDATE products SET name = '".$new_name."' WHERE shop = '1' AND id = 'a9t8'");
</div>

You are using PDO yet still open to SQL injection.

You should prepare your query, that's the whole point of PDO

$sql = "UPDATE products SET name = :new_name WHERE shop = :shop AND id = :id";
$statement = $conn->prepare($sql);
$statement->bindValue(":new_name", $new_name);
$statement->bindValue(":shop", '1');
$statement->bindValue(":id", 'a9t8');
$statement->execute();