Fix: if no results do not charge data
This commit is contained in:
parent
b6643de001
commit
353c932e11
@ -63,7 +63,7 @@ class Categorie
|
||||
* Load category into memory from database
|
||||
*
|
||||
* @param int $id Id of category
|
||||
* @param strin $label Label of category
|
||||
* @param string $label Label of category
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function fetch($id,$label='')
|
||||
@ -86,20 +86,27 @@ class Categorie
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$res = $this->db->fetch_array($resql);
|
||||
|
||||
$this->id = $res['rowid'];
|
||||
$this->fk_parent = $res['fk_parent'];
|
||||
$this->label = $res['label'];
|
||||
$this->description = $res['description'];
|
||||
$this->socid = $res['fk_soc'];
|
||||
$this->visible = $res['visible'];
|
||||
$this->type = $res['type'];
|
||||
$this->entity = $res['entity'];
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
return 1;
|
||||
if ($this->db->num_rows($resql) > 0)
|
||||
{
|
||||
$res = $this->db->fetch_array($resql);
|
||||
|
||||
$this->id = $res['rowid'];
|
||||
$this->fk_parent = $res['fk_parent'];
|
||||
$this->label = $res['label'];
|
||||
$this->description = $res['description'];
|
||||
$this->socid = $res['fk_soc'];
|
||||
$this->visible = $res['visible'];
|
||||
$this->type = $res['type'];
|
||||
$this->entity = $res['entity'];
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -265,30 +265,37 @@ class Entrepot extends CommonObject
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$obj=$this->db->fetch_object($result);
|
||||
if ($this->db->num_rows($result) > 0)
|
||||
{
|
||||
$obj=$this->db->fetch_object($result);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->libelle = $obj->label;
|
||||
$this->description = $obj->description;
|
||||
$this->statut = $obj->statut;
|
||||
$this->lieu = $obj->lieu;
|
||||
$this->address = $obj->address;
|
||||
$this->cp = $obj->zip; // deprecated
|
||||
$this->ville = $obj->town; // deprecated
|
||||
$this->pays_id = $obj->country_id; // deprecated
|
||||
$this->zip = $obj->zip;
|
||||
$this->town = $obj->town;
|
||||
$this->country_id = $obj->country_id;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
$tmp=getCountry($this->country_id,'all');
|
||||
$this->pays=$tmp['label']; // deprecated
|
||||
$this->pays_code=$tmp['code']; // deprecated
|
||||
$this->country=$tmp['label'];
|
||||
$this->country_code=$tmp['code'];
|
||||
|
||||
return 1;
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->rowid;
|
||||
$this->libelle = $obj->label;
|
||||
$this->description = $obj->description;
|
||||
$this->statut = $obj->statut;
|
||||
$this->lieu = $obj->lieu;
|
||||
$this->address = $obj->address;
|
||||
$this->cp = $obj->zip; // deprecated
|
||||
$this->ville = $obj->town; // deprecated
|
||||
$this->pays_id = $obj->country_id; // deprecated
|
||||
$this->zip = $obj->zip;
|
||||
$this->town = $obj->town;
|
||||
$this->country_id = $obj->country_id;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
$tmp=getCountry($this->country_id,'all');
|
||||
$this->pays=$tmp['label']; // deprecated
|
||||
$this->pays_code=$tmp['code']; // deprecated
|
||||
$this->country=$tmp['label'];
|
||||
$this->country_code=$tmp['code'];
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user