简体   繁体   English

MYSQL更新待批准

[英]MYSQL Update Pending Approval

I have a website where approved users can update, insert and delete data from a table. 我有一个网站,经过批准的用户可以在其中更新,插入和删除表格中的数据。 All of the final changes, however, must be approved before they are made "live" in the original table. 但是,所有最终更改必须在原始表中“生效”之前得到批准。 I want the data in the original table to be updated on a case by case basis. 我希望原始表中的数据根据​​情况进行更新。 What is the best way to go about this from the database side? 从数据库方面解决此问题的最佳方法是什么? Is it going to be triggers? 会成为触发器吗? Procedures? 程序? Transactions? 交易?

Is there a way to have a trigger on the main table, whereby, when an update is made, it will appear in the trigger table and not effect the live table? 有没有一种在主表上具有触发器的方法,当进行更新时,该更新将出现在触发器表中而不影响实时表?

Currently, my trigger looks like this. 目前,我的触发器看起来像这样。 It works but it is updating both tables. 它可以工作,但是正在更新两个表。

 DELIMITER //
CREATE TRIGGER TEST_UPDATE
BEFORE UPDATE ON test for each row
BEGIN
INSERT INTO test_changes(PERSONID, LASTNAME, FIRSTNAME, ADDRESS, CITY, TIME)
VALUES(NEW.PERSONID, NEW.LASTNAME, NEW.FIRSTNAME, NEW.ADDRESS, NEW.CITY, NEW.TIME); 
END
//

I am assuming that the actual approval/rejection process will have to be done via an admin page on the website. 我假设实际的批准/拒绝过程必须通过网站上的管理页面来完成。 From what I have read so far, MYSQL cannot prompt users for input. 从到目前为止的内容来看,MYSQL无法提示用户输入。

Thanks!! 谢谢!!

After reviewing this question, I realize I was asking for something that is directly possible with MySQL, at least not to my knowledge. 回顾了这个问题之后,我意识到我正在寻求MySQL可以直接实现的功能,至少是我所不知道的。 What I ended up doing was creating a pending changes table and then displaying it in an HTML table. 我最终要做的是创建一个挂起的更改表,然后将其显示在HTML表中。 The "admin" then goes in and approves or deny changes which will then send the changes to the appropriate tables. 然后,“管理员”进入并批准或拒绝更改,然后将更改发送到适当的表。

This could have been done in a round about way by using an active / inactive column and then displaying rows based on a column value as suggested above but it is more straightforward to just make two tables with the appropriate data. 可以通过使用活动/不活动列,然后按照上面建议的那样基于列值显示行来全面解决此问题,但是用适当的数据制作两个表会更直接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM