For my current project, i'm supposed to write a statistics page that shows data about the presence of persons (or lack thereof) per profitcenter.
(To put it roughlu, a profitcenter is a group of persons within this company, a bit like a department)
in order to generate the statistics, i'm making a list of profitcenters in my main class, then let every profitcenter fill it's own list with users.
finally, the data for a profitcenter is filled in by counting the seperate values of each person.
(for example: if a profitcenter has 3 users that both have the variable 'WPIplichtig' set to 2, the profitcenter's value would be 6).

I know this isn't optimal, but we're too close to the deadline to make any sudden changes.
The value WPIplichtig is 5 when i use a vardump at the end of the constructor of the profitcenter's constructor (from that point forward it's only using getters). when i use a vardump in the same function that made the new class, it works fine.

when i try to dump it after that, it stays on it's default value of 0, even though i'm sure it runs all the functions without error.
Here is the code from the profitcenter class:(i translated all the variable and function names to english, and removed the variables/functions that aren't necessary atm. this code works on it's own)

class DbStatProfitcenter extends DbStatStatistiekData{
    public $gebruikersLijst; //array with DbStatpersoon objects
    public $CompanyID, $WPIPlichtig; //int

    private $executed = false; //testcode, bool

    public function __construct($CompanyID){
        $list = $this->FillUsersList();


    private function FillUsersList(){
        if(!$this->dbQuery("SELECT DISTINCT gebruiker_gebruiker_id FROM gebruiker_bedrijf WHERE bedrijf_bedrijf_id ='" . $this->CompanyID . "'")){
            $this->setError("gebruikersLijst niet gevonden.");
        if($this->checkDbErrors("SELECT DISTINCT gebruiker_gebruiker_id FROM gebruiker_bedrijf WHERE bedrijf_bedrijf_id ='" . $this->CompanyID . "'") == true){
            echo("mysql error: " . mysql_error() . "<br />");
        $id_list = $this->dbFetchAll();

        return $id_list;

        grabs the data of all users that belong to this profitcenter, and adds it to it's own data.
    private function processUsers($id_list){
        for($nummer=0;$nummer < count($id_list);$nummer++){  
            $this->gebruikersLijst[$nummer] = new DbStatpersoon($id_list[$nummer]['gebruiker_gebruiker_id' ]);
            /*snip: all data not necessary for this example */
            $this->WPIPlichtig += $this->gebruikersLijst[$nummer]->getWPIPlichtig();
            $this->executed = true;
            //if this value is true, i know this function got completed.

        echo __FILE__.__LINE__.'<br />';
        //this var_dump returns the expect value.
                echo("<hr />");

the following is the function where this object is instantiated:

protected function fillProfitcenterList() {
        if(!$this->dbQuery("SELECT DISTINCT bedrijf_id, bedrijf_naam FROM bedrijf")){
            echo("profitcenterLijst niet kunnen invullen.");
        $row = $this->dbFetchAll();

        for($loop = 0;$loop < count($row);$loop++){ //1 profitcenter
            $this->ProfitcenterLijst[$loop] = new DbStatProfitcenter($row[$loop]['bedrijf_id']);
        echo __FILE__ . " " . __LINE__ . ":<br />";
        echo("<hr />");
        //this also works

and this is the file where i attempt to read the data in the profitcenter class.

foreach($this->StatistiekDB->getProfitcenterLijst() as $PC){
    $this->aantalOperationeel += $PC->getWPIPlichtig();
    echo(__FILE__.__LINE__ . ":<BR />");
    echo("<hr />");
    //returns the profitcenter class, with it's userlist filled, but without the right WPIplichtig value
    //which is set to 0

the full source code can be found in the attachment, it's in dutch, but the relevant files are called DbStatProfitcenter, DbStatStatistiek and Stat_TotaalActueel.

I rewrote part of this module, and it works now. (well, actually not completely yet, but atleast this part works)
thanks to everyone that whatched this thread, i know it's quite a bit of code and explaination.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.