author | Josh <jokajak@gmail.com> | 2011-10-05 20:40:29 (UTC) |
---|---|---|
committer | Josh <jokajak@gmail.com> | 2011-10-06 01:58:00 (UTC) |
commit | a26b219b6f4f3fee727d9b23d8cd374f6b32a4fa (patch) (side-by-side diff) | |
tree | 3ca0b96e843f5820f0bee7dede1847b014bba1e6 /backend/php/src/objects/class.recordversion.php | |
parent | 6ba274c79e60e417132b260bd0117c5a68121387 (diff) | |
download | clipperz-a26b219b6f4f3fee727d9b23d8cd374f6b32a4fa.zip clipperz-a26b219b6f4f3fee727d9b23d8cd374f6b32a4fa.tar.gz clipperz-a26b219b6f4f3fee727d9b23d8cd374f6b32a4fa.tar.bz2 |
Fix timestamps on records
- update the access and update date when a record is saved
- set the creation date when a record is created
Diffstat (limited to 'backend/php/src/objects/class.recordversion.php') (more/less context) (ignore whitespace changes)
-rw-r--r-- | backend/php/src/objects/class.recordversion.php | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/backend/php/src/objects/class.recordversion.php b/backend/php/src/objects/class.recordversion.php index 3fbc436..f2de14a 100644 --- a/backend/php/src/objects/class.recordversion.php +++ b/backend/php/src/objects/class.recordversion.php @@ -211,96 +211,98 @@ class recordversion extends POG_Base if ($GLOBALS['configuration']['db_encoding'] == 1) { $sortBy = "BASE64_DECODE($sortBy) "; } else { $sortBy = "$sortBy "; } } else { $sortBy = "$sortBy "; } } else { $sortBy = "recordversionid"; } $this->pog_query .= " order by ".$sortBy." ".($ascending ? "asc" : "desc")." $sqlLimit"; $thisObjectName = get_class($this); $cursor = Database::Reader($this->pog_query, $connection); while ($row = Database::Read($cursor)) { $recordversion = new $thisObjectName(); $recordversion->recordversionId = $row['recordversionid']; $recordversion->recordId = $row['recordid']; $recordversion->reference = $this->Unescape($row['reference']); $recordversion->header = $this->Unescape($row['header']); $recordversion->data = $this->Unescape($row['data']); $recordversion->version = $this->Unescape($row['version']); $recordversion->previous_version_key = $this->Unescape($row['previous_version_key']); $recordversion->previous_version_id = $this->Unescape($row['previous_version_id']); $recordversion->creation_date = $row['creation_date']; $recordversion->update_date = $row['update_date']; $recordversion->access_date = $row['access_date']; $recordversionList[] = $recordversion; } return $recordversionList; } /** * Saves the object to the database * @return integer $recordversionId */ function Save() { $connection = Database::Connect(); + $this->update_date = date( 'Y-m-d H:i:s'); + $this->access_date = date( 'Y-m-d H:i:s'); $this->pog_query = "select `recordversionid` from `recordversion` where `recordversionid`='".$this->recordversionId."' LIMIT 1"; $rows = Database::Query($this->pog_query, $connection); if ($rows > 0) { $this->pog_query = "update `recordversion` set `recordid`='".$this->recordId."', `reference`='".$this->Escape($this->reference)."', `header`='".$this->Escape($this->header)."', `data`='".$this->Escape($this->data)."', `version`='".$this->Escape($this->version)."', `previous_version_key`='".$this->Escape($this->previous_version_key)."', `previous_version_id`='".$this->Escape($this->previous_version_id)."', `creation_date`='".$this->creation_date."', `update_date`='".$this->update_date."', `access_date`='".$this->access_date."' where `recordversionid`='".$this->recordversionId."'"; } else { $this->pog_query = "insert into `recordversion` (`recordid`, `reference`, `header`, `data`, `version`, `previous_version_key`, `previous_version_id`, `creation_date`, `update_date`, `access_date` ) values ( '".$this->recordId."', '".$this->Escape($this->reference)."', '".$this->Escape($this->header)."', '".$this->Escape($this->data)."', '".$this->Escape($this->version)."', '".$this->Escape($this->previous_version_key)."', '".$this->Escape($this->previous_version_id)."', '".$this->creation_date."', '".$this->update_date."', '".$this->access_date."' )"; } $insertId = Database::InsertOrUpdate($this->pog_query, $connection); if ($this->recordversionId == "") { $this->recordversionId = $insertId; } return $this->recordversionId; } /** * Clones the object and saves it to the database * @return integer $recordversionId */ function SaveNew() { $this->recordversionId = ''; return $this->Save(); } @@ -333,49 +335,49 @@ class recordversion extends POG_Base for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++) { if (sizeof($fcv_array[$i]) == 1) { $pog_query .= " ".$fcv_array[$i][0]." "; continue; } else { if ($i > 0 && sizeof($fcv_array[$i-1]) !== 1) { $pog_query .= " AND "; } if (isset($this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes']) && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$fcv_array[$i][0]]['db_attributes'][0] != 'SET') { $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$this->Escape($fcv_array[$i][2])."'"; } else { $pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." '".$fcv_array[$i][2]."'"; } } } return Database::NonQuery($pog_query, $connection); } } /** * Associates the record object to this one * @return boolean */ function GetRecord() { $record = new record(); return $record->Get($this->recordId); } /** * Associates the record object to this one * @return */ function SetRecord(&$record) { $this->recordId = $record->recordId; } } -?>
\ No newline at end of file +?> |