mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-22 23:00:56 +01:00
fix SQL error when ordering by custom-field
as $order_by parameter can contain more then just order by columns, eg. group by clause
This commit is contained in:
parent
86e9b25eef
commit
508f3f81e2
@ -536,6 +536,12 @@ class Storage extends Storage\Base
|
||||
// check if we order by a custom field --> join cf table for given cf and order by it's value
|
||||
if (strpos($order_by,self::CF_PREFIX) !== false)
|
||||
{
|
||||
// if $order_by contains more then order by columns (eg. group by) split it off before
|
||||
if (($pos = stripos($order_by, 'order by')) !== false)
|
||||
{
|
||||
$group_by = substr($order_by, 0, $pos+9);
|
||||
$order_by = substr($order_by, $pos+9);
|
||||
}
|
||||
// fields to order by, as cutomfields may have names with spaces, we examine each order by criteria
|
||||
$fields2order = explode(',',$order_by);
|
||||
foreach($fields2order as $v)
|
||||
@ -578,6 +584,11 @@ class Storage extends Storage\Base
|
||||
$join .= $this->extra_join_order.' AND extra_order.'.$this->extra_key.'='.$this->db->quote($key);
|
||||
}
|
||||
}
|
||||
// add group by again
|
||||
if (isset($group_by))
|
||||
{
|
||||
$order_by = $group_by.$order_by;
|
||||
}
|
||||
}
|
||||
// check if we filter by a custom field
|
||||
if (is_array($filter))
|
||||
|
Loading…
Reference in New Issue
Block a user