public function save($deep = true, $createRevision = true) { $wasDirty = false; if ($this->isDirty && $createRevision) { // update creation time / user $this->Created = time(); $this->CreatorID = $_SESSION['User'] ? $_SESSION['User']->ID : null; $wasDirty = true; } // save record as usual $return = parent::save($deep); if ($wasDirty && $createRevision) { // save a copy to history table $recordValues = $this->_prepareRecordValues(); $set = static::_mapValuesToSet($recordValues); DB::nonQuery('INSERT INTO `%s` SET %s', array(static::$historyTable, join(',', $set))); } }
public static function delete($id) { DB::nonQuery('DELETE FROM `%s` WHERE `%s` = %u', array(static::$tableName, static::_cn(static::$primaryKey ? static::$primaryKey : 'ID'), $id), array(static::$rootClass, 'handleError')); return DB::affectedRows() > 0; }