I'm trying to add array content to database. For it i'm using
$arr = ["10","11","12","13"];
foreach ($arr as $value) {
$sql = "INSERT INTO `test` (user_id, view) VALUES (:user_id, :view)";
$stmt = $this->conn->prepare($sql);
$stmt->bindParam(':user_id', $value);
$stmt->bindParam(':view', 'small');
$stmt->execute();
}
is that good practice or bad? Is there any other good way?