Merge pull request #476 from simnandez/develop

Fix: if no results do not charge data
This commit is contained in:
Laurent Destailleur 2012-11-06 06:26:50 -08:00
commit 348674c438
2 changed files with 52 additions and 38 deletions

View File

@ -63,7 +63,7 @@ class Categorie
* Load category into memory from database * Load category into memory from database
* *
* @param int $id Id of category * @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 * @return int <0 if KO, >0 if OK
*/ */
function fetch($id,$label='') function fetch($id,$label='')
@ -86,20 +86,27 @@ class Categorie
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{ {
$res = $this->db->fetch_array($resql); if ($this->db->num_rows($resql) > 0)
{
$this->id = $res['rowid']; $res = $this->db->fetch_array($resql);
$this->fk_parent = $res['fk_parent'];
$this->label = $res['label']; $this->id = $res['rowid'];
$this->description = $res['description']; $this->fk_parent = $res['fk_parent'];
$this->socid = $res['fk_soc']; $this->label = $res['label'];
$this->visible = $res['visible']; $this->description = $res['description'];
$this->type = $res['type']; $this->socid = $res['fk_soc'];
$this->entity = $res['entity']; $this->visible = $res['visible'];
$this->type = $res['type'];
$this->db->free($resql); $this->entity = $res['entity'];
return 1; $this->db->free($resql);
return 1;
}
else
{
return 0;
}
} }
else else
{ {

View File

@ -265,30 +265,37 @@ class Entrepot extends CommonObject
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) 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->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->libelle = $obj->label; $this->libelle = $obj->label;
$this->description = $obj->description; $this->description = $obj->description;
$this->statut = $obj->statut; $this->statut = $obj->statut;
$this->lieu = $obj->lieu; $this->lieu = $obj->lieu;
$this->address = $obj->address; $this->address = $obj->address;
$this->cp = $obj->zip; // deprecated $this->cp = $obj->zip; // deprecated
$this->ville = $obj->town; // deprecated $this->ville = $obj->town; // deprecated
$this->pays_id = $obj->country_id; // deprecated $this->pays_id = $obj->country_id; // deprecated
$this->zip = $obj->zip; $this->zip = $obj->zip;
$this->town = $obj->town; $this->town = $obj->town;
$this->country_id = $obj->country_id; $this->country_id = $obj->country_id;
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
$tmp=getCountry($this->country_id,'all'); $tmp=getCountry($this->country_id,'all');
$this->pays=$tmp['label']; // deprecated $this->pays=$tmp['label']; // deprecated
$this->pays_code=$tmp['code']; // deprecated $this->pays_code=$tmp['code']; // deprecated
$this->country=$tmp['label']; $this->country=$tmp['label'];
$this->country_code=$tmp['code']; $this->country_code=$tmp['code'];
return 1; return 1;
}
else
{
return 0;
}
} }
else else
{ {