diff options
| author | Malf Furious <m@lfurio.us> | 2016-01-30 18:22:13 -0500 | 
|---|---|---|
| committer | Malf Furious <m@lfurio.us> | 2016-01-30 18:22:13 -0500 | 
| commit | bad5036569b3c572f60dae034c42a8129adc29e5 (patch) | |
| tree | 938f577a25a1f8ce933eb3151f0ab95ba8c7f59e | |
| parent | 86d179fbb5ece5d69184ecd885a2b29818e9a57e (diff) | |
| download | scrott-bad5036569b3c572f60dae034c42a8129adc29e5.tar.gz scrott-bad5036569b3c572f60dae034c42a8129adc29e5.zip | |
Handle object timestamps automatically in Object::saveObj()
The saveObj() function now initializes and update the timeCreated and timeUpdated fields of objects on its own.
A new function, getCurrentTimestamp() (from class Object) is introduced to aid simpler fetching of the date and time
Diffstat (limited to '')
| -rw-r--r-- | app/class/object.class.php | 14 | 
1 files changed, 14 insertions, 0 deletions
| diff --git a/app/class/object.class.php b/app/class/object.class.php index bcd8dfa..93b52f0 100644 --- a/app/class/object.class.php +++ b/app/class/object.class.php @@ -77,6 +77,8 @@ abstract class Object extends Framework      {          if (isset($this->guid))          { +            $this->timeUpdated = $this->getCurrentTimestamp(); +              /* Update Base */              $updateStr = ""; @@ -117,6 +119,8 @@ abstract class Object extends Framework          else          {              $this->guid = $this->getNewGUID(); +            $this->timeCreated = $this->getCurrentTimestamp(); +            $this->timeUpdated = $this->timeCreated;              /* Insert Base */              $colsStr = ""; @@ -180,6 +184,16 @@ abstract class Object extends Framework      }      /* +     * Get current timestamp for object database purposes +     */ +    function getCurrentTimestamp() +    { +        $query = "SELECT now() AS stamp"; +        $result = $this->db->query($query); +        return $result[0]['stamp']; +    } + +    /*       * Check whether given GUID exists       */      function isGUID($guid) | 
