It will enter ELSE
either you do <= todays_date
or >= todays_date
, since NULL
is neither bigger or smaller.
You should have something on the query that fuels that value_from_db to not return you NULL values OR validate specifically for them in the IF.
Here's a procedure to test that:
CREATE TABLE datet(date1 DATE);
INSERT INTO datet VALUES(null);
CREATE PROCEDURE validateNullDate()
RETURNING char(5)
DEFINE dateVar DATE;
SELECT date1 INTO dateVar FROM datet;
IF dateVar <= TODAY THEN
RETURN "if";
ELSE
RETURN "else";
END IF
END PROCEDURE;
Even changing the IF to: IF dateVar >= TODAY THEN
. You'll always get "else".
EDIT:
About your question of getting strtotime(NULL)
smaller than today, you can find a good explanation on this answer:
NULL is interpreted as 0 by strtotime, since it want to be passed an integer timestamp. A timestamp of 0 means 1-1-1970.
So it will go in the if.