mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 14:41:29 +01:00
adding again error message and number from DB to exception thrown in case of SQL errors, also adding a new method to abstract MySQL group_contact for PostgreSQL 8.4+
This commit is contained in:
parent
9a4693822c
commit
287abb2b38
@ -674,7 +674,8 @@ class egw_db
|
|||||||
if (!$this->Query_ID)
|
if (!$this->Query_ID)
|
||||||
{
|
{
|
||||||
throw new egw_exception_db_invalid_sql("Invalid SQL: ".(is_array($Query_String)?$Query_String[0]:$Query_String).
|
throw new egw_exception_db_invalid_sql("Invalid SQL: ".(is_array($Query_String)?$Query_String[0]:$Query_String).
|
||||||
($inputarr ? "<br>Parameters: '".implode("','",$inputarr)."'":''));
|
"\n$this->Error ($this->Errno)".
|
||||||
|
($inputarr ? "\nParameters: '".implode("','",$inputarr)."'":''));
|
||||||
}
|
}
|
||||||
return $this->Query_ID;
|
return $this->Query_ID;
|
||||||
}
|
}
|
||||||
@ -1173,6 +1174,37 @@ class egw_db
|
|||||||
return call_user_func_array(array(&$this->Link_ID,'concat'),$args);
|
return call_user_func_array(array(&$this->Link_ID,'concat'),$args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Concat grouped values of an expression with optional order and separator
|
||||||
|
*
|
||||||
|
* @param string $expr column-name or expression optional prefixed with "DISTINCT"
|
||||||
|
* @param string $order_by='' optional order
|
||||||
|
* @param string $separator=',' optional separator, default is comma
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function group_concat($expr, $order_by='', $separator=',')
|
||||||
|
{
|
||||||
|
switch($this->Type)
|
||||||
|
{
|
||||||
|
case 'mysql':
|
||||||
|
$sql = 'GROUP_CONCAT('.$expr;
|
||||||
|
if ($order_by) $sql .= ' ORDER BY '.$order_by;
|
||||||
|
if ($separator != ',') $sql .= ' SEPARATOR '.$this->quote($separator);
|
||||||
|
$sql .= ')';
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'pgsql': // requires for Postgresql < 8.4 to have a custom ARRAY_AGG method installed!
|
||||||
|
$sql = 'ARRAY_TO_STRING(ARRAY_AGG('.$expr;
|
||||||
|
if ($order_by) $sql .= ' ORDER BY '.$order_by;
|
||||||
|
$sql .= '), '.$this->quote($separator).')';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: // probably gives an sql error anyway
|
||||||
|
$sql = $expr;
|
||||||
|
}
|
||||||
|
return $sql;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a DB specific timestamp in a unix timestamp stored as integer, like MySQL: UNIX_TIMESTAMP(ts)
|
* Convert a DB specific timestamp in a unix timestamp stored as integer, like MySQL: UNIX_TIMESTAMP(ts)
|
||||||
*
|
*
|
||||||
@ -1192,7 +1224,6 @@ class egw_db
|
|||||||
case 'mssql':
|
case 'mssql':
|
||||||
return "DATEDIFF(second,'1970-01-01',($expr))";
|
return "DATEDIFF(second,'1970-01-01',($expr))";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user