Merge pull request #3574 from FHenry/3.8

FIX : avoid SQL error when no sortfield send to method (price by customer)
This commit is contained in:
Laurent Destailleur 2015-09-23 18:21:21 +02:00
commit d633118bd4
2 changed files with 15 additions and 14 deletions

View File

@ -1083,18 +1083,18 @@ abstract class CommonObject
function getValueFrom($table, $id, $field)
{
$result=false;
$sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$row = $this->db->fetch_row($resql);
$result = $row[0];
}
if (!empty($id) && !empty($field) && !empty($table)) {
$sql = "SELECT ".$field." FROM ".MAIN_DB_PREFIX.$table;
$sql.= " WHERE rowid = ".$id;
dol_syslog(get_class($this).'::getValueFrom', LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
$row = $this->db->fetch_row($resql);
$result = $row[0];
}
}
return $result;
}

View File

@ -351,8 +351,9 @@ class Productcustomerprice extends CommonObject
}
}
}
$sql.= $this->db->order($sortfield, $sortorder);
if (!empty($sortfield)) {
$sql.= $this->db->order($sortfield, $sortorder);
}
if (! empty($limit)) $sql .= ' ' . $this->db->plimit($limit + 1, $offset);
dol_syslog(get_class($this) . "::fetch_all", LOG_DEBUG);