From 602921ebd65b8a46190bbcf1eb7a83c409f2c926 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 13 Apr 2017 21:05:56 -0400 Subject: Add table function refreshObj() --- app/class/table.class.php | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app/class/table.class.php') diff --git a/app/class/table.class.php b/app/class/table.class.php index 45be8c5..ac21aaf 100644 --- a/app/class/table.class.php +++ b/app/class/table.class.php @@ -67,6 +67,15 @@ abstract class table } } + /* + * This function uses loadObj to re-initialize this object, if in + * the case it gets modified in another scope. + */ + public function refreshObj() : void + { + $this->loadObj($this->guid); + } + /* * This function will update this object in the database, or insert new * data if this object does not yet have a GUID. This function uses the -- cgit v1.2.3 From e7228676ce51bf69cc974fc0bd8f8135c51fd036 Mon Sep 17 00:00:00 2001 From: Malf Furious Date: Thu, 13 Apr 2017 23:23:56 -0400 Subject: Fix bug in table function saveObj() While creating new objects, some default values (defined in the database schema) are missing in the PHP object definition. To address this, now while saving any *new* database objects, all undefined, expected fields are set to the empty string "". --- app/class/table.class.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'app/class/table.class.php') diff --git a/app/class/table.class.php b/app/class/table.class.php index ac21aaf..c547e43 100644 --- a/app/class/table.class.php +++ b/app/class/table.class.php @@ -127,7 +127,10 @@ abstract class table foreach ($flds as $fld) { if (!isset($this->$fld)) + { + $this->$fld = ""; continue; + } $fld = database::esc($fld); $fldstr .= $fld . ", "; -- cgit v1.2.3