Reputation: 215
I have a customer table that I cannot change. It has a varchar field, that contains either NULL or 5.
I am trying to change that to a 1/0 (tinyint 1) in my field.
if ($row['varfield'] == '7') {
$row['varfield'] = 1;
} else {
$row['varfield'] = 0;
}
$stmt = $db->prepare("INSERT INTO table(col1) VALUES(?)");
$stmt->execute(array($row['varfield']));
However I am getting the error in my SQL saying that the col1 cannot be nullable...
Upvotes: 1
Views: 203
Reputation: 67948
However I am getting the error in my SQL saying that the col1 cannot be nullable...
So set the column to be nullable in the database.
Upvotes: 1