v5:reference:connection:ifnull
This is an old revision of the document!
ifNull
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);
v5/reference/connection/ifnull.1452648662.txt.gz · Last modified: 2017/04/21 11:34 (external edit)