|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-10-31 18:22 UTC] boccara at netvision dot net dot il
Description:
------------
Hello I have a defined a class that manage a 2 dimensions array (table).
I have created 2 oblect of this class.
These oblect are inside a loop , a fetch from an sql query (MSSQL).
The oblects received data from the query.
Teh problem is that after a certain number of times in the loop ( always the same number of times depending to the query), I got an error message:
Call to a member function on a non-object
when are called the function of the created object.
This is very strange, the created object seems to be deleted !!
I use Zend Studio, I use the debugger to search the bug, but there is no syntax bug or anything else !?
Reproduce code:
---------------
class TotDevisParEditeur
{
var $VecEditeur = array();
var $value = array();
function GetValue($type,$editeur)
{
return $this->VecEditeur[$editeur][$type];
}
function Display($type,$editeur)
{
echo $this->VecEditeur[$editeur][$type];
endl();
}
function AddDevis($type,$editeur,$numOfdevis)
{
$value[$type] = $this->GetValue($type,$editeur) + $numOfdevis;
$this->VecEditeur[$editeur] = $value;
$this->Display($type,$editeur);
}
}
/////////////////////////////////////////////////////////
$SousTotal = new TotDevisParEditeur;
$SousTotalCom = array();
$SousTotalCom['gagne'] = new TotDevisParEditeur;
$SousTotalCom['perdu'] = new TotDevisParEditeur;
$SousTotalCom['encours'] = new TotDevisParEditeur;
while (dbFetch($iTableTmp, $Col))
{
/*
in this portion of code there is no redefinition of the object !!
just value are assigned to $RefEditeur, $Gagne,...
*/
$SousTotal->AddDevis('gagne',$RefEditeur,$Gagne);
$SousTotal->AddDevis('perdu',$RefEditeur,$Perdu);
$SousTotal->AddDevis('encours',$RefEditeur,$Encours);
$SousTotalCom['gagne']->AddDevis($Gestionnaire,$RefEditeur,$Gagne);
$SousTotalCom['perdu']->AddDevis($Gestionnaire,$RefEditeur,$Perdu);
$SousTotalCom['encours']->AddDevis($Gestionnaire,$RefEditeur,$Encours);
}
Expected result:
----------------
.... results .....
************************************
0000010215-------VR------>
0
0
2
6---- VR ------>
0
0
2
************************************
0000010215-------CA2------>
0
0
1
6---- CA2 ------>
2
0
1
************************************
0000010215-------VR------>
0
0
1
6---- VR ------>
0
0
3
************************************
0000008896-------VR------>
************************
instead of the error it should continue !!!!!!!!!!!!
*************************
Actual result:
--------------
last section of the result
************************************
0000010215-------VR------>
0
0
2
6---- VR ------>
0
0
2
************************************
0000010215-------CA2------>
0
0
1
6---- CA2 ------>
2
0
1
************************************
0000010215-------VR------>
0
0
1
6---- VR ------>
0
0
3
************************************
0000008896-------VR------>
Fatal error: Call to a member function on a non-object in c:\Program Files\Apache Group\Apache2\htdocs\speedevis\lib\StatRev.inc.php on line 2018
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Nov 22 09:00:02 2025 UTC |
dbfetch us an function created to choose a fetch according to the database. in our case it is MSSQL. this function works already since 4 years. Function dbFetch ($iResult, &$tabColonne) { $iNbCol = 0; // Permet de recuperer une erreur ou le nombre de colonnes $tabColonne = array(); switch (SGBD) { case "ODBC": $iNbCol = odbc_fetch_into($iResult, &$tabColonne); break; case "MSQL": $tabColonne = mysql_fetch_row($iResult); if($tabColonne) $iNbCol = count($tabColonne); break; case "MSSQL": $tabColonne = mssql_fetch_array($iResult); if($tabColonne) { $iNbCol = count($tabColonne); } break; } return $iNbCol; }the line 2018 in the fatal error is: $SousTotal->AddDevis('gagne',$RefEditeur,$Gagne);function endl() { echo "<br>"; }