ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:reference:connection:ifnull

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
Next revisionBoth sides next revision
reference:ifnull [2015/07/20 03:36] – created mnewnhamreference:ifnull [2015/07/20 13:53] – [Usage] mnewnham
Line 10: Line 10:
 The function ''ifNull()'' returns a database-specific string providing the means to replace a null value with a specified replacement. The two parameters are: The function ''ifNull()'' returns a database-specific string providing the means to replace a null value with a specified replacement. The two parameters are:
  
- - The field in the table to check. +  - The field in the table to check. 
- - The value to replace the null value with if it is found+  - The value to replace the null value with if it is found
  
 ===== Usage ===== ===== Usage =====
 <code php> <code php>
 +/*
 + * 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);
 </code> </code>
v5/reference/connection/ifnull.txt · Last modified: 2016/01/16 23:34 by mnewnham