配列検索を使用して重複データの挿入をスキップします。配列検索PHP mysql PDO
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '053fb04a34907637530dcb86b9f121f5fe499821' for key 'id'"
$check=$this->pdo->prepare("select id from user_places");
$check->execute();
$a = $check->fetchAll(PDO::FETCH_COLUMN, 0);
for ($i = 0; $i < count($output->results); $i++) {
if (array_search($data[$i]['id'], $a) == "") {
$query->bindparam(1,$data[$i]['id']);
$query->bindparam(2,$data[$i]['name']);
$query->bindparam(3,$data[$i]['lat']);
$query->bindparam(4,$data[$i]['lng']);
$query->bindparam(5,$data[$i]['place_id']);
$query->bindparam(6,$data[$i]['types']);
$query->bindparam(7,$data[$i]['vicinity']);
$query->execute();
}
}