diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 16ebb0e77e9..1a29103239f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -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; } diff --git a/htdocs/product/class/productcustomerprice.class.php b/htdocs/product/class/productcustomerprice.class.php index 1bca4579070..dd072e19a2f 100644 --- a/htdocs/product/class/productcustomerprice.class.php +++ b/htdocs/product/class/productcustomerprice.class.php @@ -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);