I am trying to delete entries using PDO:
$query = $pdo->prepare("DELETE FROM matches
WHERE sportsmen_id IN (:sportsmenIds)
AND game_id = :gameId
AND category_id = :categoryId
AND place_id IN (:placeIds)");
$query->bindValue('sportsmenIds', rtrim($sportsmenIds, ','));
$query->bindValue('gameId', $gameId);
$query->bindValue('categoryId', $categoryId);
$query->bindValue('placeIds', rtrim($placeIds, ','));
$query->execute();`
I even tried dumping the query and the values and it resulted correct:
{
"sportsmenIds": "17117",
"gameId": 15073,
"categoryId": 47295,
"placeIds": "10,38,40,37",
"query": "DELETE FROM matches WHERE sportsmen_id IN
(:sportsmenIds) AND game_id = :gameId AND
category_id =
:categoryId AND place_id IN (:placeId)"
}
But what's deleted are only entries where place_id = 10 (the first place_id in $placeIds)
I also suspect that if I got more than 1 $sportsmenIds, same thing will also happen, only the first from $sportsmenIds will also be deleted.
What I am expecting:
For all the entries that met the condition of sportsmen_id, game_id, category_id, and all values for place_id inside IN STATEMENT, not just the place_id = 10