From 4caf68e6ff02a9c9627efa2acb2ce50c2f7aca7b Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 10 Jul 2012 11:38:58 +0200 Subject: [PATCH] Properly refresh data when using autoloading by unsetting all internal variables. --- class.databaserecord.php | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/class.databaserecord.php b/class.databaserecord.php index 7e3b0cd..bf78673 100644 --- a/class.databaserecord.php +++ b/class.databaserecord.php @@ -69,6 +69,25 @@ abstract class CPHPDatabaseRecordClass extends CPHPBaseClass { $this->PurgeCache(); $this->ConstructDataset($this->sId); + + if($this->autoloading === true) + { + $this->PurgeVariables(); + } + } + + public function PurgeVariables() + { + foreach($this->prototype as $type => $dataset) + { + foreach($dataset as $field) + { + $variable_name_safe = "s" . $field; + $variable_name_unsafe = "u" . $field; + unset($this->$variable_name_safe); + unset($this->$variable_name_unsafe); + } + } } public function ConstructDataset($uDataSource, $defaultable = null)