ModelBackup

Filepath: phork/php/ext/helpers/ModelBackup.class.php

The ModelBackup class is a model helper that handles backing up records into a separate table before editing or deleting them. For example if a user needs deleting from the regular table but should exist in a user backup table somewhere.


Example (from a model constructor)

//back up the record before saving over it
if (AppLoader::includeExtension('helpers/', 'ModelBackup')) {
    $this->appendHelper('backup', 'ModelBackup', array(
        'BackupTable' => 'foo-deleted'
    ));
    $this->initHelper('backup', array('backupSave'), array(
        'Batch' => true,
        'Fatal' => false
    ));
}

//back up the record before deleting it
if (AppLoader::includeExtension('helpers/', 'ModelBackup')) {
    $this->appendHelper('backup', 'ModelBackup', array(
        'BackupTable' => 'foo-deleted'
    ));
    $this->initHelper('backup', array('backupDelete'), array(
        'Batch' => true,
        'Fatal' => false
    ));
}