I want to insert some data into my MySql table using PDO. If it's not empty it will have Integer datatype so i use PDO::PARAM_INT, but the problem is this data is not required so sometimes it's empty.
It make me have an error:
PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value.
So is it anyway I can pass this empty value variable into my database without having error when it have empty value? here's my code snippet:
$stmt = $db->prepare("INSERT INTO table (column) VALUES (:column)");
$stmt->bindParam(':column',$_POST['value'], PDO::PARAM_INT);
$stmt->execute();