Add a 'forced' option to InsertIntoDatabase, to pre-fill all data instead of lazy-loading

develop
Sven Slootweg 11 years ago
parent 161dd60fd7
commit 6822c353c3

@ -355,7 +355,7 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass
}
}
public function InsertIntoDatabase()
public function InsertIntoDatabase($force_data = false)
{
global $cphp_config, $database;
@ -382,6 +382,29 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass
}
}
if($force_data === true)
{
foreach($this->prototype as $type_key => $type_value)
{
foreach($type_value as $element_key => $element_value)
{
$variable_name_unsafe = "u" . $element_key;
if(!isset($this->$variable_name_unsafe))
{
foreach($this->prototype as $type => $dataset)
{
if(isset($dataset[$element_key]))
{
$column_name = $dataset[$element_key];
$this->$variable_name_unsafe = $this->uData[$column_name];
}
}
}
}
}
}
$element_list = array();
foreach($this->prototype as $type_key => $type_value)

Loading…
Cancel
Save