At 06:57 28/10/2007, you wrote:
Message-ID: <4724328C.90608@xxxxxxxxx>
Date: Sun, 28 Oct 2007 14:56:12 +0800
From: Ronald Wiplinger <ronald@xxxxxxxxx>
I need some hints how to do that. Maybe there is a template or an
easy function available.
I have a MySQL database with some tables. Everytime a table record
changes, I want also put the old record to a history database.
The history table and the original only differs that the key of the
original will be just a field in the backup, while the new key is
now the UNIX time stamp.
How can I do that "easy"?
"Easy" is to set a MySQL5 trigger which does the Insert on update :
http://dev.mysql.com/doc/refman/5.0/en/triggers.html
eg (from the manual page) :
DELIMITER |
CREATE TRIGGER testref BEFORE INSERT ON test1
FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1;
DELETE FROM test3 WHERE a3 = NEW.a1;
UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
END;
|
HTHCheers - Neil
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php