mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-11 08:28:43 +01:00
added concat function to abstract different concat operators or functions
This commit is contained in:
parent
01d480cad1
commit
7d5faa667a
@ -275,7 +275,6 @@
|
||||
{
|
||||
return False;
|
||||
}
|
||||
if (is_array($str)) $this->halt('db::db_addslashes('.print_r($str,True).",'$type') 1. arguments is an array!!!");
|
||||
// the substring is needed as the string is already in quotes
|
||||
return substr($this->Link_ID->quote($str),1,-1);
|
||||
}
|
||||
@ -859,6 +858,31 @@ if (is_array($str)) $this->halt('db::db_addslashes('.print_r($str,True).",'$type
|
||||
$this->connect();
|
||||
}
|
||||
|
||||
/**
|
||||
* concat a variable number of strings together, to be used in a query
|
||||
*
|
||||
* Example: $db->concat($db->quote('Hallo '),'username') would return
|
||||
* for mysql "concat('Hallo ',username)" or "'Hallo ' || username" for postgres
|
||||
* @param $str1 string already quoted stringliteral or column-name, variable number of arguments
|
||||
* @return string to be used in a query
|
||||
*/
|
||||
function concat($str1)
|
||||
{
|
||||
$args = func_get_args();
|
||||
|
||||
// REMOVE-IF-ONLY-ADODB
|
||||
if (isset($GLOBALS['phpgw_info']['server']['use_adodb']) &&
|
||||
!@$GLOBALS['phpgw_info']['server']['use_adodb'])
|
||||
{
|
||||
return $this->Type == 'mysql' ? 'concat('.implode(',',$args).')' : implode('||',$args);
|
||||
}
|
||||
if (!$this->Link_ID && !$this->connect())
|
||||
{
|
||||
return False;
|
||||
}
|
||||
return call_user_func_array(array(&$this->Link_ID,'concat'),$args);
|
||||
}
|
||||
|
||||
/**
|
||||
* Correctly Quote Identifiers like table- or colmnnames for use in SQL-statements
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user