Fix: Correction pb fecth_object

This commit is contained in:
Laurent Destailleur 2005-03-21 19:12:35 +00:00
parent af9e19a0bc
commit b278f1adff

View File

@ -106,7 +106,7 @@ if ($account > 0)
if ($result) if ($result)
{ {
$var=True; $var=True;
$num = $db->num_rows(); $num = $db->num_rows($result);
$i = 0; $i = 0;
$options = "<option value=\"0\" SELECTED></option>"; $options = "<option value=\"0\" SELECTED></option>";
while ($i < $num) while ($i < $num)
@ -114,14 +114,14 @@ if ($account > 0)
$obj = $db->fetch_object($result); $obj = $db->fetch_object($result);
$options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++; $options .= "<option value=\"$obj->rowid\">$obj->label</option>\n"; $i++;
} }
$db->free(); $db->free($result);
} }
/* /*
* *
* *
*/ */
$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."bank as b"; $sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."bank as b";
$sql .= " WHERE b.fk_account=".$acct->id; $sql .= " WHERE b.fk_account=".$acct->id;
$sql_rech=""; $sql_rech="";
if ($_POST["req_desc"]) if ($_POST["req_desc"])
@ -137,11 +137,12 @@ if ($account > 0)
if ($_POST["req_credit"]) $sql_rech.=" AND amount = ".$_POST["req_credit"]; if ($_POST["req_credit"]) $sql_rech.=" AND amount = ".$_POST["req_credit"];
$sql .= $sql_rech; $sql .= $sql_rech;
if ( $db->query($sql) ) $result=$db->query($sql);
if ($result)
{ {
$nbline = $db->result (0, 0); $obj = $db->fetch_object($result);
$nbline = $obj->nb;
$total_lines = $nbline; $total_lines = $nbline;
$db->free();
if ($nbline > $viewline ) if ($nbline > $viewline )
{ {
@ -151,6 +152,11 @@ if ($account > 0)
{ {
$limit = $viewline; $limit = $viewline;
} }
$db->free($result);
}
else {
dolibarr_print_error($db);
} }
if ($page > 0 && $mode_search == 0) if ($page > 0 && $mode_search == 0)
@ -256,7 +262,7 @@ if ($account > 0)
$result = $db->query($sql); $result = $db->query($sql);
if ($result) if ($result)
{ {
_print_lines($db, $sql, $acct); _print_lines($db, $result, $sql, $acct);
$db->free($result); $db->free($result);
} }
@ -317,17 +323,16 @@ llxFooter("<em>Derni&egrave;re modification $Date$ r&eacute;vision $Revision$</e
/* /*
* *
*/ */
function _print_lines($db,$sql,$acct) function _print_lines($db,$result,$sql,$acct)
{ {
global $bc, $nbline, $viewline, $user, $page; global $bc, $nbline, $viewline, $user, $page;
$var=True; $var=True;
$num = $db->num_rows(); $num = $db->num_rows($result);
$i = 0; $total = 0; $i = 0; $total = 0; $sep = 0;
$sep = 0;
while ($i < $num) while ($i < $num)
{ {
$objp = $db->fetch_object(); $objp = $db->fetch_object($result);
$total = $total + $objp->amount; $total = $total + $objp->amount;
$time = time(); $time = time();
if ($i >= ($nbline - $viewline)) if ($i >= ($nbline - $viewline))