0

Estoy editando un registro que contiene un campo tipo INT para lo cual uso

$stmt->bindParam(5, $qte_cntId, PDO::PARAM_INT);

sucede que el campo, en algunos casos, puede ser NULL entonces me retorna el error Incorrect integer value obviamente si lo valido como NULL

$stmt->bindParam(5, $qte_cntId, PDO::PARAM_NULL);

si $qte_cntId viene con valor != NULL lo deja en NULL

Como lo valido para que lo actualice correctamente?

1 respuesta 1

1

Usando el operador ternario:

$stmt->bindParam(5, $qte_cntId, isset($qte_cntId) ? PDO::PARAM_INT : PDO::PARAM_NULL);
1
  • Asi funciona bien!
    – wings77
    el 29 jun. 2019 a las 14:51

Tu Respuesta

By clicking “Publica tu respuesta”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

¿No es la respuesta que buscas? Examina otras preguntas con la etiqueta o formula tu propia pregunta.