Re: MySQL Conditional Trigger

From: Date: Mon, 08 Dec 2008 23:25:00 +0000
Subject: Re: MySQL Conditional Trigger
References: 1 2 3 4  Groups: php.db 
Request: Send a blank email to php-db+get-45780@lists.php.net to get a copy of this message
Fortuno, Adam wrote:
All, Chris makes a good point i.e., "unknown compared to anything is unknown". His comment made me want to clarify my earlier note. In my earlier example, I wasn't suggesting that-that logic be coded in the database. I was assuming it would be in the page: <?php $TestNullValue = NULL; If ($TestNullValue) { print "Evaluates to true!"; } else { print "Evaluates to false!"; } ?> I tested this, and it worked. Here is why, PHP (like pretty much every other language) silently casts a NULL to false: "When converting to boolean, the following values are considered FALSE: - the boolean FALSE itself - the integer 0 (zero) - the float 0.0 (zero) - the empty string, and the string "0" - an array with zero elements - an object with zero member variables (PHP 4 only) - the special type NULL (including unset variables)" ("Booleans", php.net, 05 Dec. 2008).
If you use the shortcut php check, but you can do it the longer way. if ($value !== null) { ... } Can you turn off email notifications too please? It's rather annoying when it's on a public mailing list. -- Postgresql & php tutorials http://www.designmagick.com/

« previous php.db (#45780) next »