Fix: Removed warning during migrate

This commit is contained in:
Laurent Destailleur 2011-08-14 00:09:30 +00:00
parent 9eea2e86af
commit 8e5d33da45

View File

@ -22,7 +22,7 @@
/** /**
* \defgroup societe Module societe * \defgroup societe Module societe
* \brief Module to manage third parties (customers, prospects) * \brief Module to manage third parties (customers, prospects)
* \version $Id: modSociete.class.php,v 1.122 2011/08/10 00:50:18 eldy Exp $ * \version $Id: modSociete.class.php,v 1.123 2011/08/14 00:09:30 eldy Exp $
*/ */
/** /**
@ -206,6 +206,8 @@ class modSociete extends DolibarrModules
// Add extra fields // Add extra fields
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company'"; $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'company'";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$fieldname='extra.'.$obj->name; $fieldname='extra.'.$obj->name;
@ -213,6 +215,7 @@ class modSociete extends DolibarrModules
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_entities_array[$r][$fieldname]='company'; $this->export_entities_array[$r][$fieldname]='company';
} }
}
// End add axtra fields // End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s';
@ -240,6 +243,8 @@ class modSociete extends DolibarrModules
// Add extra fields // Add extra fields
$sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact'"; $sql="SELECT name, label FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'contact'";
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) // This can fail when class is used on old database (during migration for example)
{
while ($obj=$this->db->fetch_object($resql)) while ($obj=$this->db->fetch_object($resql))
{ {
$fieldname='extra.'.$obj->name; $fieldname='extra.'.$obj->name;
@ -247,6 +252,7 @@ class modSociete extends DolibarrModules
$this->export_fields_array[$r][$fieldname]=$fieldlabel; $this->export_fields_array[$r][$fieldname]=$fieldlabel;
$this->export_entities_array[$r][$fieldname]='contact'; $this->export_entities_array[$r][$fieldname]='contact';
} }
}
// End add axtra fields // End add axtra fields
$this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_start[$r]='SELECT DISTINCT ';
$this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c'; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'socpeople as c';