Try to avoid to make subquery when not necessary

This commit is contained in:
Laurent Destailleur 2019-03-07 12:43:17 +01:00 committed by GitHub
parent c31318f29d
commit a0bc6672d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -563,18 +563,22 @@ class Adherent extends CommonObject
$sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest $sql.= ", fk_user_mod = ".($user->id>0?$user->id:'null'); // Can be null because member can be create by a guest
$sql.= " WHERE rowid = ".$this->id; $sql.= " WHERE rowid = ".$this->id;
$sql2 = "SELECT libelle"; // If we change the type of membership, we set also label of new type
$sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; if (! empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid)
$sql2.= " WHERE rowid = ".$this->typeid; {
$resql2 = $this->db->query($sql2); $sql2 = "SELECT libelle as label";
if($resql2) $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type";
{ $sql2.= " WHERE rowid = ".$this->typeid;
while ($obj=$this->db->fetch_object($resql2)) $resql2 = $this->db->query($sql2);
{ if ($resql2)
$this->type=$obj->libelle; {
} while ($obj=$this->db->fetch_object($resql2))
} {
$this->type=$obj->label;
}
}
}
dol_syslog(get_class($this)."::update update member", LOG_DEBUG); dol_syslog(get_class($this)."::update update member", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)