This commit is contained in:
Laurent Destailleur 2019-10-08 13:14:51 +02:00
parent 51be0fad99
commit 760783b98b

View File

@ -842,11 +842,14 @@ class Categorie extends CommonObject
if ($type=="contact") { if ($type=="contact") {
$subcol_name="fk_socpeople"; $subcol_name="fk_socpeople";
} }
$idoftype = array_search($type, self::$MAP_ID_TO_CODE);
$sql = "SELECT s.rowid"; $sql = "SELECT s.rowid";
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub "; $sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
$sql.= ' WHERE s.entity IN ('.getEntity('category').')'; $sql.= ' WHERE s.entity IN ('.getEntity('category').')';
$sql.= ' AND s.type='.array_search($type, self::$MAP_ID_TO_CODE); $sql.= ' AND s.type='.$idoftype;
$sql.= ' AND s.rowid = sub.fk_categorie'; $sql.= ' AND s.rowid = sub.fk_categorie';
$sql.= ' AND sub.'.$subcol_name.' = '.$id; $sql.= ' AND sub.'.$subcol_name.' = '.$id;
@ -865,7 +868,7 @@ class Categorie extends CommonObject
} }
} }
$sql.= $this->db->plimit($limit + 1, $offset); if ($limit) $sql.= $this->db->plimit($limit + 1, $offset);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)