1

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

2 Answers 2

5

PDO doesn't have a "close" function. You can do

$this->db = null;

In your case, on $stmt

Sign up to request clarification or add additional context in comments.

Comments

2

Use $stmt = null; instead of $stmt->close();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.