Clean code

This commit is contained in:
Laurent Destailleur 2019-03-15 19:11:24 +01:00
parent c0b6699b25
commit a1adcc785c

View File

@ -93,29 +93,22 @@ class CUnits // extends CommonObject
if (isset($this->unit_type)) $this->active=trim($this->unit_type); if (isset($this->unit_type)) $this->active=trim($this->unit_type);
if (isset($this->active)) $this->active=trim($this->active); if (isset($this->active)) $this->active=trim($this->active);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values
// Insert request // Insert request
$sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units("; $sql = "INSERT INTO ".MAIN_DB_PREFIX."c_units(";
$sql.= "rowid,"; $sql.= "rowid,";
$sql.= "code,"; $sql.= "code,";
$sql.= "label,"; $sql.= "label,";
$sql.= "short_label,"; $sql.= "short_label,";
$sql.= "unit_type"; $sql.= "unit_type";
$sql.= ") VALUES ("; $sql.= ") VALUES (";
$sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").","; $sql.= " ".(! isset($this->id)?'NULL':"'".$this->db->escape($this->id)."'").",";
$sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").","; $sql.= " ".(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").",";
$sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").",";
$sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->escape($this->short_label)."'").","; $sql.= " ".(! isset($this->short_label)?'NULL':"'".$this->db->escape($this->short_label)."'").",";
$sql.= " ".(! isset($this->unit_type)?'NULL':"'".$this->db->escape($this->unit_type)."'"); $sql.= " ".(! isset($this->unit_type)?'NULL':"'".$this->db->escape($this->unit_type)."'");
$sql.= ")"; $sql.= ")";
$this->db->begin(); $this->db->begin();
@ -187,7 +180,6 @@ class CUnits // extends CommonObject
if ($unit_type) $sql_where[]= " t.unit_type = '".$this->db->escape($unit_type)."'"; if ($unit_type) $sql_where[]= " t.unit_type = '".$this->db->escape($unit_type)."'";
if ($code) $sql_where[]= " t.code = '".$this->db->escape($code)."'"; if ($code) $sql_where[]= " t.code = '".$this->db->escape($code)."'";
if ($short_label) $sql_where[]= " t.short_label = '".$this->db->escape($short_label)."'"; if ($short_label) $sql_where[]= " t.short_label = '".$this->db->escape($short_label)."'";
if (count($sql_where)>0) { if (count($sql_where)>0) {
$sql.=' WHERE '. implode(' AND ', $sql_where); $sql.=' WHERE '. implode(' AND ', $sql_where);
} }
@ -322,7 +314,6 @@ class CUnits // extends CommonObject
if (isset($this->unit_type)) $this->libelle=trim($this->unit_type); if (isset($this->unit_type)) $this->libelle=trim($this->unit_type);
if (isset($this->active)) $this->active=trim($this->active); if (isset($this->active)) $this->active=trim($this->active);
// Check parameters // Check parameters
// Put here code to add control on parameters values // Put here code to add control on parameters values