FIX sql syntax error when sort order not defined.

This commit is contained in:
Laurent Destailleur 2015-10-13 14:40:02 +02:00
parent 70f3da80df
commit 57ea4fc23d
2 changed files with 3 additions and 2 deletions

View File

@ -226,7 +226,7 @@ abstract class DoliDB implements Database
*/
function order($sortfield=null,$sortorder=null)
{
if (isset($sortfield))
if (! empty($sortfield))
{
$return='';
$fields=explode(',',$sortfield);
@ -236,7 +236,7 @@ abstract class DoliDB implements Database
else $return.=',';
$return.=preg_replace('/[^0-9a-z_\.]/i','',$val);
if (isset($sortorder))
if (! empty($sortorder))
{
$return.=' '.preg_replace('/[^0-9a-z]/i','',$sortorder);
}

View File

@ -229,6 +229,7 @@ $sql.= " AND p.fk_statut = 1";
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " GROUP BY s.nom, s.rowid";
$sql.= $db->order($sortfield, $sortorder);
$var=true;
$resql = $db->query($sql);