Browse Source

Fix error management

Laurent Destailleur 10 years ago
parent
commit
e667c3e916
1 changed files with 4 additions and 3 deletions
  1. 4 3
      dev/skeletons/skeleton_class.class.php

+ 4 - 3
dev/skeletons/skeleton_class.class.php

@@ -136,7 +136,7 @@ class Skeleton_Class extends CommonObject
      *
      *  @param	int		$id    	Id object
      *  @param	string	$ref	Ref
-     *  @return int          	<0 if KO, >0 if OK
+     *  @return int          	<0 if KO, 0 if not found, >0 if OK
      */
     function fetch($id,$ref='')
     {
@@ -154,7 +154,8 @@ class Skeleton_Class extends CommonObject
         $resql=$this->db->query($sql);
         if ($resql)
         {
-            if ($this->db->num_rows($resql))
+        	$numrows = $this->db->num_rows($resql);
+            if ($numrows)
             {
                 $obj = $this->db->fetch_object($resql);
 
@@ -165,7 +166,7 @@ class Skeleton_Class extends CommonObject
             }
             $this->db->free($resql);
 
-            return 1;
+            return ($numrows?1:0);
         }
         else
         {