This one's stumped me...
I have built a PHP report generator which is designed to spit out static HTML pages containing tables of data pulled from a database. My boss wants static pages in the interests of speed and because the information only changes once a week.
I'm running the script on WinNT4.SP6 with PHP 5.0.0 Beta [I can't rule out a bug in PHP 5].
When I run the script, one of a list of about 6000 sql queries are then run in sequence, the results are put in an object variable and then another object method deals with the information and formats it accordingly.
However, when I run it, PHP.exe shows up in task manager, eating away at memory fast - about 1 meg every second gets consumed and it generates about 7000 page faults every second too. [I've no idea what page faults are but there's lots of them...]. But it still works, and the information comes out ok.
I've isolated the fault as being a result of multiple calls to ODBC_DO() to extract the queries. I can't figure out where my error is. Is it a PHP bug, the way I've built my object, the way I pass variables? Any help would be appreciated as I'm really stuck on this one..... So here's a cut down version of the code, which replicates the fault but has all the unnecessary stuff chopped.
Thanks
Chris
<?
$card = new treemapper();
$card->process();
class treemapper
{
var $dbDSN = "ScoreCardTest2";
var $dbUserName = "";
var $dbUserPassword = "";
var $dbConnection;
var $queryResults; //for the above.
var $iteratorValue = 1;
Function treemapper()
{
$this->dbConnect();
}
Function dbConnect()
{
$this->dbConnection = odbc_connect($this->dbDSN, $this->dbUserName, $this->dbUserPassword);
}
Function dbClose()
{
odbc_close($this->dbConnection);
}
Function runSQLQuery($query)
{
$results = odbc_do($this->dbConnection, $query);
if (!$results)
{
die("SQL Query Failed");
}
return $results;
}
function process()
{
for ($nval=1;$nval<=700;$nval++)
{
$this->taskMaster();
}
}
function taskMaster()
{
$this->iteratorValue += 1;
$this->queryResults = $this->runSQLQuery("SELECT * from SALES where ID = $this->iteratorValue");
}
}