I have the following code to save an array in my DB:
public function agregarBolsasModel($datos, $tabla) {
$datosL=array($datos["valoresBox"]);
$stmt = Conexion::conectar() -> prepare("INSERT INTO $tabla(lote, caja, bolsa)VALUES(:one, :two, :three)");
for($p = 0; $p < sizeof($datosL); $p++) {
$stmt -> bindParam(":one", $datos["loteNum"], PDO::PARAM_INT);
$stmt -> bindParam(":two", $datos["cajaNum"], PDO::PARAM_INT);
$stmt -> bindParam(":three", $datosL[$p], PDO::PARAM_INT);
$stmt->execute();
}
$stmt->close();
}
The value of three is an array like [1,2,3] where I don't know the size cause it's a dynamic array, but I can't save the data in my DB, also when I tried to save the data I received the following error:
Fatal error>: Uncaught error: Call to undefined method PDOStatement::close()
what is my mistake? How could I do to fix that?
Thanx