Imagine this select statement in MySQL:
SELECT table1.place, table2.person FROM table1, table2
If “place” or “person” is empty in the database (NULL or if it was mistakenly entered as an empty string of length zero), I want it to insert null in that variable once I get it into a PHP array… instead, it is showing up as string of length zero.
The first question is, why would this be happening?
The second question is, as a fix, I was thinking to assign it a string if the DB field is a string of length zero or null – this way we are taking ownership of the issue…
What’s the best fix here?
update
Just to add, the point here is to get this for use in Smarty. With Smarty, isset() evaluates “true” on a string of zero length, AND it seems to evaluate true even for a NULL inside those variables, so maybe this is more of a smarty issue??
You could use
NULLIF: