0

私はCMSに取り組んでいて、バックアップ/復元機能を追加したいと思っていました。保存したエントリを編集するたびにバックアップして、クライアントが変更を加えた場合に不満を感じたり、何かを台無しにしたりした場合に、元に戻って以前の状態を選択して復元できるようにします。

私が抱えている問題は、この機能をコーディングするという概念に頭を悩ませようとしていることです。「ID、日付、時刻、pageName、およびpageContent」フィールドを使用して「backup」という新しいテーブルを作成しましたが、そこから先に進むと行き詰まります。

複製をバックアップテーブルに保存する新しいクエリを編集スクリプトに追加しますか?そして、保存されたいくつかの編集ごとにのみバックアップするようにするにはどうすればよいですか?

ここに、保存編集クエリがあります。前もって感謝します!:)

<?php
        $_POST['entry'] = mysql_real_escape_string($_POST['entry']);
        $sql="update pageEntry set entry=\"$_POST[entry]\", pageName=\"$_POST[pageName]\" where id=\"$_POST[id]\"";       
        $result=mysql_query($sql)or die('Bad Query');
            echo "<div id='edit2'>The file has been uploaded, and your information has been added to the directory<br /></div>";  
?>
4

1 に答える 1

1

Version control at the table level is usually done by adding a version column to your existing table. So if you had a posts table you would add a version column with a simple int or date value. Every time a post is edited a new record is inserted and the version number bumped. You can reference this version number in another table or have an additional active field to denote which post is the latest/active.

If you're talking about rolling back the database I would use the mysqldump command to dump and mysql to restore.

于 2012-06-06T15:08:41.383 に答える