Fix: Remove sql error when no link

This commit is contained in:
Laurent Destailleur 2011-03-01 09:34:23 +00:00
parent 49993b3c5e
commit 49698b1c03

View File

@ -1540,44 +1540,48 @@ 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).")";
dol_syslog("Propal::InvoiceArrayList sql=".$sql);
$resql=$this->db->query($sql);
if ($resql)
{ {
$tab_sqlobj=array(); $sql= "SELECT rowid as facid, facnumber, total, datef as df, fk_user_author, fk_statut, paye";
$nump = $this->db->num_rows($resql); $sql.= " FROM ".MAIN_DB_PREFIX."facture";
for ($i = 0;$i < $nump;$i++) $sql.= " WHERE rowid IN (".implode(',',$linkedInvoices).")";
{
$sqlobj = $this->db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj;
}
$this->db->free($resql);
$nump = sizeOf($tab_sqlobj); dol_syslog("Propal::InvoiceArrayList sql=".$sql);
$resql=$this->db->query($sql);
if ($nump) if ($resql)
{ {
$i = 0; $tab_sqlobj=array();
while ($i < $nump) $nump = $this->db->num_rows($resql);
{ for ($i = 0;$i < $nump;$i++)
$obj = array_shift($tab_sqlobj); {
$sqlobj = $this->db->fetch_object($resql);
$tab_sqlobj[] = $sqlobj;
}
$this->db->free($resql);
$ga[$i] = $obj; $nump = sizeOf($tab_sqlobj);
$i++; if ($nump)
} {
} $i = 0;
return $ga; while ($i < $nump)
} {
else $obj = array_shift($tab_sqlobj);
{
return -1; $ga[$i] = $obj;
$i++;
}
}
return $ga;
}
else
{
return -1;
}
} }
else return $ga;
} }
/** /**