You are here

function date_sql_concat in Date 8

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

A helper function to do cross-database concatation of date parts.

Parameters

array $array: An array of values to be concatonated in sql.

Return value

string Correct sql string for database type.

File

date_api/date_api.module, line 683
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_concat($array) {
  switch (db_driver()) {
    case 'mysql':
    case 'mysqli':
      return "CONCAT(" . implode(",", $array) . ")";
    case 'pgsql':
      return implode(" || ", $array);
  }
}