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,15 +563,19 @@ 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
if (! empty($this->oldcopy) && $this->typeid != $this->oldcopy->typeid)
{
$sql2 = "SELECT libelle as label";
$sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type"; $sql2.= " FROM ".MAIN_DB_PREFIX."adherent_type";
$sql2.= " WHERE rowid = ".$this->typeid; $sql2.= " WHERE rowid = ".$this->typeid;
$resql2 = $this->db->query($sql2); $resql2 = $this->db->query($sql2);
if($resql2) if ($resql2)
{ {
while ($obj=$this->db->fetch_object($resql2)) while ($obj=$this->db->fetch_object($resql2))
{ {
$this->type=$obj->libelle; $this->type=$obj->label;
}
} }
} }