From 2f5932026e69a8865f06730e06c6e51c0bc0276a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 13 Dec 2013 18:33:05 +0100 Subject: [PATCH] More information returned into return code --- htdocs/core/class/commonobject.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 869a989e55d..aa53d92d6c6 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2049,7 +2049,7 @@ abstract class CommonObject * * @param int $rowid Id of line * @param array $optionsArray Array resulting of call of extrafields->fetch_name_optionals_label() - * @return void + * @return int <0 if error, 0 if no optionals to find nor found, 1 if a line is found and optionnal loaded */ function fetch_optionals($rowid,$optionsArray='') { @@ -2077,7 +2077,8 @@ abstract class CommonObject $resql=$this->db->query($sql); if ($resql) { - if ($this->db->num_rows($resql)) + $numrows=$this->db->num_rows($resql); + if ($numrows) { $tab = $this->db->fetch_array($resql); @@ -2093,12 +2094,17 @@ abstract class CommonObject } $this->db->free($resql); + + if ($numrows) return $numrows; + else return 0; } else { dol_print_error($this->db); + return -1; } } + return 0; } /**