From a shipping form $_POST['seleccion']
that is a list of codes, the amount varies depending on whether it is selected in the form.
In the controller I separate the codes and invoke the class:
$eliminar = implode(',', $_POST['seleccion']);
$eliminaAlumno = new Alumnos();
$OK = $eliminaAlumno->eliminar($eliminar);
The class is the following:
public function eliminar($lista) {
$bd = new Conn();
$IN = str_repeat('?,', count($lista) - 1) . '?';
$sql = "DELETE FROM tabla WHERE cod IN ($IN)";
$sth = $bd->prepare($sql);
$sth->bindParam(1, $lista, PDO::PARAM_INT);
$sth->execute();
}
I used as a basis this question I added < em> bindParam to verify that all codes are Integer . The problem is that it only deletes one record and not all the codes it receives. What is the problem?