Freeside:4:Documentation:Developer/FS/h Common

From Freeside
Jump to: navigation, search

NAME

FS::h_Common - History table "mixin" common base class

SYNOPSIS

package FS::h_tablename; @ISA = qw( FS::h_Common FS::tablename );

sub table { 'h_table_name'; }

sub insert { return "can't insert history records manually"; } sub delete { return "can't delete history records"; } sub replace { return "can't modify history records"; }

DESCRIPTION

FS::h_Common is intended as a "mixin" base class for history table classes to inherit from.

METHODS

sql_h_search END_TIMESTAMP [ START_TIMESTAMP ]
Returns an a list consisting of the "SELECT", "EXTRA_SQL", SQL fragments, a placeholder for "CACHE_OBJ" and an "AS" SQL fragment, to search for the appropriate history records created before END_TIMESTAMP and (optionally) not deleted before START_TIMESTAMP.
sql_h_searchs END_TIMESTAMP [ START_TIMESTAMP ]
Like sql_h_search, but limited to the single most recent record (before END_TIMESTAMP)
sql_diff START_TIMESTAMP, END_TIMESTAMP[, WHERE]
Returns a complete SQL statement to find all records that were changed between START_TIMESTAMP and END_TIMESTAMP. This finds only replacements, not new or deleted records.
For each modified record, this will return one row (not two rows as in the history table) with the primary key of the record, "old_historynum" (the historynum of the last modification before START_TIMESTAMP), and "new_historynum" (the last modification before END_TIMESTAMP). Join these back to the h_* table to retrieve the actual field values.
Within the query, the last history records as of START and END are aliased as "old" and "new"; you can append a WHERE clause to take advantage of this.

BUGS

SEE ALSO

FS::Record, schema.html from the base documentation