I have a weird issue which I'm sure is because I don't understand all the idiosyncrasies of MySQL :(
I have a table with a column that has the default value of NULL, "TeamID". When I add a new row without giving a value for that column, it is NULL. Perfect. Except when I wish to update that row, the following code doesn't seem to change the value from NULL (or even cause any error):
$STH = $this->_db->prepare("UPDATE UserDetails SET
TeamID = ':teamID' WHERE UserID = ':userID';");
$STH->execute($params);
To restate the problem: I have a problem overwriting TeamID with a non-nullable value if it's already NULL. I can't see where there's any error in the code itself, so I'm imagining it's something to do with the NULL value.
One problem coding with PHP/MySQL is that you can't step through your code and look at the contents of the database at the same time -- because PHPMyAdmin gets stepped through, too.
Thanks for any help!
':teamID'=>:teamID, lose the quotes, around every single placeholder, doesn't matter which type.:varin a field?':var'should insert the literal:var, not go looking for a parameter:var). Casting-wise this would be:':var'(enter value=>)'NULL'(cast to int =>)0And @Farray was a bit earlier with the answer, although maybe a little less explicit/clear.