Okay, I got it working. Seems this was a bug in PHP, but it was fixed somewhere in the 5.2 version
Here is my updated code (note two important things, before copying and pasting 1) I overwrote your getAllNewlyInsertedRecords() method and I commented out your setLookupData method)
<?php
class SetGetBase {
protected $properties;
protected $allowed_props;
public function __construct(){}
// Set undeclared property. Allow only the property names
// defined in the allowed_props array
function __set($property, $value){
if(in_array($property, $this->allowed_props)){
$this->properties[$property] = $value;
} else {
throw new exception("The $property is not allowed");
}
}
// get defined property
function & __get($property){
return $this->properties[$property];
}
protected function getAllProperities(){
return $this->properties;
}
}
class AggregateImportedLeads extends SetGetBase {
public function __construct(){
/*
* The properties are not passed into the object
* the magic methods __set() and __get() are handling
* this so you need to ensure that you set the value
* after instantiating the values like $o_CreateUser->o_SaltHash = new SaltHash();
* or $o_CreateUser->username = 'mike.johnson';
*/
$this->properties = array();
$this->allowed_props = array(
'o_Db'
,'o_UserManage'
,'o_Validate'
,'temp_table_name'
,'lead_sources'
,'groups'
,'affinities'
,'arrangements'
,'locations'
,'genders'
,'years_of_births'
,'married_status'
,'languages'
,'user_dates'
,'lead_dates'
);
}
protected function setLookupData(){
// Get the Lead Source Ids and Names
$results = $this->getTable('lead_sources', 'lead_source_id,lead_source');
$this->lead_sources = $this->createDataArray($results);
//$this->viewList('Lead Sources',$this->lead_sources);
// Get the Group Ids and Names
$results = $this->getTable('groups', 'group_id,group_name');
$this->groups = $this->createDataArray($results);
//$this->viewList('Groups',$this->groups);
// Get the Affinities Ids and Names
$results = $this->getTable('lk_affinities', 'id,affinity');
$this->affinities = $this->createDataArray($results);
//$this->viewList('Affinities',$this->affinities);
// Get the Arrangements Ids and Names
$results = $this->getTable('arrangement_types', 'arrangement_id,arrangement_name');
$this->arrangements = $this->createDataArray($results);
//$this->viewList('Arrangements',$this->arrangements);
// Get the Locations Ids and Names
$results = $this->getTable('locations', 'location_id,location_name');
$this->locations = $this->createDataArray($results);
//$this->viewList('Locations',$this->locations);
// Get the Gender Ids and Names
$results = $this->getTable('lk_genders', 'gender_id,gender');
$this->genders = $this->createDataArray($results);
//$this->viewList('Genders',$this->genders);
// Get the Years(of birth) Ids and Names
$results = $this->getTable('years', 'year_id,year');
$this->years_of_births = $this->createDataArray($results);
//$this->viewList('Years (of Birth)',$this->years_of_births);
// Get the Married Statuses Ids and Names
$results = $this->getTable('marital_status', 'marital_status_id,marital_status_name');
$this->married_status = $this->createDataArray($results);
//$this->viewList('Marital Statuses',$this->married_status);
// Get the Language Ids and Names
$results = $this->getTable('lk_languages', 'language_id,language');
$this->languages = $this->createDataArray($results);
//$this->viewList('Languages',$this->languages);
}
private function getAllNewlyInsertedRecords()
{
return array(
array(
'date_entered' => '2012-03-04',
'date_registered' => '2012-03-04',
'date_modified' => '2012-07-01'
),
array(
'date_entered' => '2012-03-05',
'date_registered' => '2012-03-05',
'date_modified' => '2012-07-02'
),
array(
'date_entered' => '2012-03-06',
'date_registered' => '2012-03-06',
'date_modified' => '2012-07-03'
)
);
}
public function aggregateData(){
echo 'Temp Table Name: ' . $this->temp_table_name . '<br />';
/*
* Set all arrays of the ids and data for every lookup
* the inserts will require to insert reference to each lookup by ID
*/
//$this->setLookupData();
/*
* Get the imported CSV data from the temporary table
*/
$rows = $this->getAllNewlyInsertedRecords();
/*
* Set up variables that need their scope outside the for loops
* This is needed if there is a sales manager but no advisor. In
* this case, the switch sets the advisor to the same values as
* the sales manager so the variables from the previous inside foreach
* loop needs to be maintained to allow the values to be set.
*/
//$lead_dates = array();
//$user_dates = array();
foreach($rows as $users){
foreach($users as $key => $value){
switch($key){
// match the column names returned in the queried results
case 'date_entered':
case 'date_registered':
case 'date_modified':
$this->lead_dates[$key] = $value;
if($key == 'date_entered' || $key == 'date_registered'){
$this->user_dates[$key] = $value;
}
break;
default:
if(method_exists($this, $key)){
$this->$key($key,$value);
}
}
echo 'lead dates: '; echo var_dump($this->lead_dates) . '<br />';
echo 'user dates: '; echo var_dump($this->user_dates) . '<br />';
//$this->o_UserManage;
}
}
}
}
$test = new AggregateImportedLeads();
$test->aggregateData();
?>
Okay, so the first thing I did was make __get by reference (per the URL I provided). The second thing I did was change how the __get functions, in other words I removed the IF array_key_exists check, it now just attempts to return the value at that location no matter what (doesn’t seem to throw any notices if the key doesn’t exist since it is by reference).
Hope this helps.