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 @@ -163,219 +163,221 @@ class recordversion extends POG_Base */ function GetList($fcv_array = array(), $sortBy='', $ascending=true, $limit='') { $connection = Database::Connect(); $sqlLimit = ($limit != '' ? "LIMIT $limit" : ''); $this->pog_query = "select * from `recordversion` "; $recordversionList = Array(); if (sizeof($fcv_array) > 0) { $this->pog_query .= " where "; for ($i=0, $c=sizeof($fcv_array); $i<$c; $i++) { if (sizeof($fcv_array[$i]) == 1) { $this->pog_query .= " ".$fcv_array[$i][0]." "; continue; } else { if ($i > 0 && sizeof($fcv_array[$i-1]) != 1) { $this->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') { if ($GLOBALS['configuration']['db_encoding'] == 1) { $value = POG_Base::IsColumn($fcv_array[$i][2]) ? "BASE64_DECODE(".$fcv_array[$i][2].")" : "'".$fcv_array[$i][2]."'"; $this->pog_query .= "BASE64_DECODE(`".$fcv_array[$i][0]."`) ".$fcv_array[$i][1]." ".$value; } else { $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$this->Escape($fcv_array[$i][2])."'"; $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value; } } else { $value = POG_Base::IsColumn($fcv_array[$i][2]) ? $fcv_array[$i][2] : "'".$fcv_array[$i][2]."'"; $this->pog_query .= "`".$fcv_array[$i][0]."` ".$fcv_array[$i][1]." ".$value; } } } } if ($sortBy != '') { if (isset($this->pog_attribute_type[$sortBy]['db_attributes']) && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'NUMERIC' && $this->pog_attribute_type[$sortBy]['db_attributes'][0] != 'SET') { 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(); } /** * Deletes the object from the database * @return boolean */ function Delete() { $connection = Database::Connect(); $this->pog_query = "delete from `recordversion` where `recordversionid`='".$this->recordversionId."'"; return Database::NonQuery($this->pog_query, $connection); } /** * Deletes a list of objects that match given conditions * @param multidimensional array {("field", "comparator", "value"), ("field", "comparator", "value"), ...} * @param bool $deep * @return */ function DeleteList($fcv_array) { if (sizeof($fcv_array) > 0) { $connection = Database::Connect(); $pog_query = "delete from `recordversion` where "; 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 +?> |