====== ifNull ======
~~NOTOC~~
string ifNull(
string $fieldToCheck,
mixed $replacementValue
)
===== Description ====
The function ''ifNull()'' returns a database-specific string providing the means to replace a null value with a specified replacement. If the value in the database is not null, the value is not updated. The two parameters are:
- The field in the table to check.
- The value to replace the null value with if it is found
===== Usage =====
/*
* Assume mysql database connection
*/
$ifNullString = $db->ifNull('pants_field','chinos');
/*
* ifnullString returns 'CASE WHEN pants_field is null
THEN 'chinos'
ELSE pants_field
END ";
*/
$SQL = "UPDATE attire
SET pants_field = $ifNullString";
$db->Execute($SQL);