You are here

function date_sql_coalesce in Date 8

Same name and namespace in other branches
  1. 5.2 date_api_sql.inc \date_sql_coalesce()
  2. 6.2 date_api_sql.inc \date_sql_coalesce()
  3. 7.3 date_api/date_api_sql.inc \date_sql_coalesce()
  4. 7 date_api/date_api_sql.inc \date_sql_coalesce()
  5. 7.2 date_api/date_api_sql.inc \date_sql_coalesce()

Helper function to do cross-database NULL replacements

Parameters

array $array: An array of values to test for NULL values.

Return value

string SQL statement to return the first non-NULL value in the list.

File

date_api/date_api.module, line 702
This module will make the date API available to other modules. Designed to provide a light but flexible assortment of functions and constants, with more functionality in additional files that are not loaded unless other modules specifically include them.

Code

function date_sql_coalesce($array) {
  switch (db_driver()) {
    case 'mysql':
    case 'mysqli':
    case 'pgsql':
      return "COALESCE(" . implode(',', $array) . ")";
  }
}