I have a string that is used for an INSERT command. When values are empty, the corresponding spot in the INSERT string is being generated as:
VALUES ('', 'VALUE', '', '', '', 0, 1, '')
I want to replace the '' with NULL so the database no longer throws an error about casting varchar to type numeric:
VALUES (null, 'VALUE', null, null, null, 0, 1, null)
I tried using:
$build_values_m = str_replace($build_values_m, ", '', ", ", null, ");
However, that takes away most of my INSERT string and does not JUST replace the empty values with NULL.
How can I do this?
"''"with"NULL"? That is not what yourstr_replaceis attempting to do (not even close).('','','VALUE HERE','',)??