简体   繁体   English

PHP / MySQL-编辑批准系统

[英]PHP / MySQL - approval system for edits

I have a business listings website. 我有一个商家信息网站。 I am currently building an interface for users to log in and update their listings. 我目前正在建立一个界面,供用户登录并更新其列表。

The functionality I would like to implement is as follows: 我要实现的功能如下:

  1. user edits listing and submits 用户编辑列表并提交
  2. the edits are sent to admin for approval 编辑将发送给管理员以供批准
  3. in the meantime the existing listing remains on the site 同时,现有列表仍保留在网站上
  4. admin reviews the edits and corrects any mistakes before approving 管理员在批准之前查看修改内容并更正任何错误

Now usually something like this can be accomplished by storing a 'duplicate' row in the database, with a flag set to 'pending'. 现在通常可以通过在数据库中存储“重复”行并将标志设置为“待处理”来完成类似的操作。

However if possible I would like to try a different approach, as the listing data is stored across several tables, including one which contains multiple category selections. 但是,如果可能的话,我想尝试一种不同的方法,因为列表数据存储在多个表中,包括一个包含多个类别选择的表。

So ideally I would prefer not to create additional database records. 因此,理想情况下,我宁愿不创建其他数据库记录。 Is there a better alternative I could use? 我可以使用更好的替代方法吗?

There are actually 2 different approaches. 实际上有2种不同的方法。

  1. Use the database (either in the same tables, or some "pending changes" tables with almost the same structure as the original ones), although one way or another it creates records. 使用数据库(可以在同一表中,也可以在某些“待更改”表中使用与原始表几乎相同的结构),尽管它会以某种方式创建记录。

  2. Don't use the database at all, but some intermediate store (key / value store; message queue; memcache; email;just some files; whatever comes to mind ;)) 根本不使用数据库,而是使用一些中间存储(键/值存储;消息队列;内存缓存;电子邮件;仅一些文件;什么都可以想到;))

With option 2 you can easily do as the 2 commenters on your question already said: create a data structure and serialize this structure and store it anywhere until the admin "approves" the data and updates it in the database. 使用选项2时,您可以轻松地按已回答您的问题的2条评论者的意见进行操作:创建数据结构并序列化此结构并将其存储在任何地方,直到管理员“批准”数据并在数据库中更新它。

At first glance the second option would of course be quicker to implement, although implementing it in the database could give you the ability to "rollback" changes by using a current or state flag. 乍一看,第二个选项当然可以更快地实现,尽管在数据库中实现它可以使您能够通过使用current或state标志来“回滚”更改。 Secondly, imho, you want to keep all your (related) data close together to keep it maintainable 其次,恕我直言,您希望将所有(相关)数据保持在一起以保持可维护性

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

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