Introducing sql_concat() - and use it in sql_fullname()

sql_concat() is just a passthrough to $db->Concat() -- it doesn't
add any value, and I think the dispatching is somewhat expensive.

Just using $db->Concat() should be good enough, were it not for
consistency in our DM API.
This commit is contained in:
martinlanghoff
2006-09-26 05:02:59 +00:00
parent 6e58026b29
commit 0ce96669c9
+15 -11
View File
@@ -1231,18 +1231,22 @@ function sql_ilike() {
* @return string
*/
function sql_fullname($firstname='firstname', $lastname='lastname') {
global $CFG;
return sql_concat($firstname, "' '", $lastname);
}
switch ($CFG->dbtype) {
case 'mysql':
return ' CONCAT('. $firstname .'," ",'. $lastname .') ';
case 'postgres7':
return " ". $firstname ."||' '||". $lastname ." ";
case 'mssql':
return " ". $firstname ."+' '+". $lastname ." ";
default:
return ' '. $firstname .'||" "||'. $lastname .' ';
}
/**
* Returns the proper SQL to do CONCAT between the elements passed
* Can take many parameters - just a passthrough to $db->Concat()
*
* @uses $db
* @param string $element
* @return string
*/
function sql_concat() {
global $db;
$args = func_get_args();
return call_user_func_array(array('Concat', $db), $args);
}
/**