Fix sort order use last sortorder if several fields.
This commit is contained in:
parent
b1b7a7c725
commit
980cb095da
@ -229,6 +229,7 @@ abstract class DoliDB implements Database
|
||||
{
|
||||
if (! empty($sortfield))
|
||||
{
|
||||
$oldsortorder = '';
|
||||
$return='';
|
||||
$fields=explode(',', $sortfield);
|
||||
$orders=explode(',', $sortorder);
|
||||
@ -238,15 +239,19 @@ abstract class DoliDB implements Database
|
||||
if (! $return) $return.=' ORDER BY ';
|
||||
else $return.=', ';
|
||||
|
||||
$return.=preg_replace('/[^0-9a-z_\.]/i', '', $val);
|
||||
$return .= preg_replace('/[^0-9a-z_\.]/i', '', $val); // Add field
|
||||
|
||||
$tmpsortorder = trim($orders[$i]);
|
||||
|
||||
// Only ASC and DESC values are valid SQL
|
||||
if (strtoupper($tmpsortorder) === 'ASC') {
|
||||
$oldsortorder = 'ASC';
|
||||
$return .= ' ASC';
|
||||
} elseif (strtoupper($tmpsortorder) === 'DESC') {
|
||||
$oldsortorder = 'DESC';
|
||||
$return .= ' DESC';
|
||||
} else {
|
||||
$return .= ' '.($oldsortorder ? $oldsortorder : 'ASC');
|
||||
}
|
||||
|
||||
$i++;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user