Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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.
  • Loading branch information...
commit 0ce96669c97beef23c6875953bfc15c79f42e1ce 1 parent 6e58026
martinlanghoff authored
Showing with 15 additions and 11 deletions.
  1. +15 −11 lib/dmllib.php
View
26 lib/dmllib.php
@@ -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);
}
/**
Please sign in to comment.
Something went wrong with that request. Please try again.