Fix: Remove sql error when no link

This commit is contained in:
Laurent Destailleur 2011-03-01 09:33:59 +00:00
parent eee0d1aa07
commit d34a653734

View File

@ -1540,45 +1540,49 @@ class Propal extends CommonObject
} }
} }
$sql= "SELECT rowid as facid, facnumber, total, datef as df, fk_user_author, fk_statut, paye"; if (sizeof($linkedInvoices) > 0)
$sql.= " FROM ".MAIN_DB_PREFIX."facture"; {
$sql.= " WHERE rowid IN (".implode(',',$linkedInvoices).")"; $sql= "SELECT rowid as facid, facnumber, total, datef as df, fk_user_author, fk_statut, paye";
$sql.= " FROM ".MAIN_DB_PREFIX."facture";
$sql.= " WHERE rowid IN (".implode(',',$linkedInvoices).")";
dol_syslog("Propal::InvoiceArrayList sql=".$sql); dol_syslog("Propal::InvoiceArrayList sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
if ($resql) if ($resql)
{ {
$tab_sqlobj=array(); $tab_sqlobj=array();
$nump = $this->db->num_rows($resql); $nump = $this->db->num_rows($resql);
for ($i = 0;$i < $nump;$i++) for ($i = 0;$i < $nump;$i++)
{ {
$sqlobj = $this->db->fetch_object($resql); $sqlobj = $this->db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj; $tab_sqlobj[] = $sqlobj;
} }
$this->db->free($resql); $this->db->free($resql);
$nump = sizeOf($tab_sqlobj); $nump = sizeOf($tab_sqlobj);
if ($nump) if ($nump)
{ {
$i = 0; $i = 0;
while ($i < $nump) while ($i < $nump)
{ {
$obj = array_shift($tab_sqlobj); $obj = array_shift($tab_sqlobj);
$ga[$i] = $obj; $ga[$i] = $obj;
$i++; $i++;
} }
} }
return $ga; return $ga;
} }
else else
{ {
return -1; return -1;
} }
} }
else return $ga;
}
/** /**
* \brief Efface propal * \brief Efface propal