1
I am editing this question to be more didactic for other members, since there are only publications addressing this situation outside the community en.
I own a field INT property UNIQUE that may have value NULL.
The value that will be inserted in this field comes from a variable that may have value NULL. The problem is that by doing the INSERT, if this variable has a null value, the value 0 (zero) in this field, which will cause problems when entering a new record thanks to the property UNIQUE.
Follow the example that will generate this error:
$varExemplo = null;
$sql = "INSERT INTO usuario (campoIntExemplo) VALUES ('".$varExemplo."');
$query = $mysqli->query(sql);
What will be the difference between an Index and the other? could detail better?
– Caique Romero
Why are you saving like zero? I ask you to put an example of your
INSERT
in full.– Zulian
I edited the publication to be more explanatory.
– Hugo Guitti