string ifNull(
string $fieldToCheck,
mixed $replacementValue
)
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:
/* * 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);