You are here

function date_sql_coalesce in Date 7

Same name and namespace in other branches
  1. 8 date_api/date_api.module \date_sql_coalesce()
  2. 5.2 date_api_sql.inc \date_sql_coalesce()
  3. 6.2 date_api_sql.inc \date_sql_coalesce()
  4. 7.3 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

an array of values to test for NULL values:

Return value

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

File

date_api/date_api_sql.inc, line 34
SQL helper for Date API.

Code

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