Okay, I have no idea what's going on here. I have an update query that two of the three fields are working exactly as I need, but no matter how much I pre-format the value for it, it still always comes up as a quoted 'NULL' in my dumped query rather than NULL as demonstrated below.
This is how I am pre-formatting my field values;
$val1 = (is_null($item1Val)) ? 'NULL' : "'" . stripslashes(json_encode($item1Val)) . "'";
$val2 = (is_null($item2Val)) ? 'NULL' : "'" . stripslashes(json_encode($item2Val)) . "'";
$val3 = (is_null($item3Val)) ? 'NULL' : "'" . trim($item3Val) . "'";
This is the update query string I'm using in my code. I've tried using string concatenation also and that seems to yield the exact same issue;
$dml = "UPDATE table SET
field_1 = $val1,
field_2 = $val2,
field_3 = $val3,
WHERE id = $id;";
THIS, however, is how it appears when I dump the query;
UPDATE table SET
field_1 = NULL,
field_2 = NULL,
field_3 = 'NULL',
WHERE id = $id;
I have dumped the values that are coming in as the raw data and each of them come in as true NULL values, which is precisely what I am wanting. So, if they are all coming in as true NULL values, then how is the last variable being turned into a quote value rather than the first two working exactly as desired? I have no clue what I could be missing here.
This is driving me nuts!