From 1c9f283e17ff9a571d37a0493f530091686ec4df Mon Sep 17 00:00:00 2001 From: eldy Date: Sun, 14 Aug 2011 02:09:06 +0200 Subject: [PATCH] Fix: Removed warning during migrate process --- htdocs/includes/modules/modSociete.class.php | 26 ++++++++++++-------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index 6adaa84391d..5c75193d74f 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -216,12 +216,15 @@ class modSociete extends DolibarrModules // Add extra fields $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company'"; $resql=$this->db->query($sql); - while ($obj=$this->db->fetch_object($resql)) + if ($resql) // This can fail when class is used on old database (during migration for example) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_entities_array[$r][$fieldname]='company'; + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_entities_array[$r][$fieldname]='company'; + } } // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; @@ -250,12 +253,15 @@ class modSociete extends DolibarrModules // Add extra fields $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact'"; $resql=$this->db->query($sql); - while ($obj=$this->db->fetch_object($resql)) + if ($resql) // This can fail when class is used on old database (during migration for example) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_entities_array[$r][$fieldname]='contact'; + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_entities_array[$r][$fieldname]='contact'; + } } // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT ';