Fix: if no results do not charge data

This commit is contained in:
simnandez 2012-11-06 12:33:35 +01:00
parent b6643de001
commit 353c932e11
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='')
@ -85,6 +85,8 @@ class Categorie
dol_syslog(get_class($this)."::fetch sql=".$sql); dol_syslog(get_class($this)."::fetch sql=".$sql);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql)
{
if ($this->db->num_rows($resql) > 0)
{ {
$res = $this->db->fetch_array($resql); $res = $this->db->fetch_array($resql);
@ -102,6 +104,11 @@ class Categorie
return 1; return 1;
} }
else else
{
return 0;
}
}
else
{ {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;

View File

@ -264,6 +264,8 @@ class Entrepot extends CommonObject
dol_syslog(get_class($this)."::fetch sql=".$sql); dol_syslog(get_class($this)."::fetch sql=".$sql);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result)
{
if ($this->db->num_rows($result) > 0)
{ {
$obj=$this->db->fetch_object($result); $obj=$this->db->fetch_object($result);
@ -291,6 +293,11 @@ class Entrepot extends CommonObject
return 1; return 1;
} }
else else
{
return 0;
}
}
else
{ {
$this->error=$this->db->error(); $this->error=$this->db->error();
return -1; return -1;