PHP MySQL - 每周一次的操作 [英] PHP MySQL – Once a Week Operations

查看:40
本文介绍了PHP MySQL - 每周一次的操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处理订单的数据库 - 订单在流程开始时插入,但如果流程未完成(他们离开页面等),则未填写已确认"字段,这允许管理员知道哪些订单已完成.

I've got a database that processes an order - the Order is inserted at the beginning of the process but if the process is not complete (they left the page etc) the "confirmed" field is not filled in, this allows the admin to know which orders were complete or not.

目前我无法调整网站管理数据的方式,但是我可以添加某种每周清理这些已确认"= 0 的数据库字段.

At the moment I don't have the luxury of adjusting the way the website manages the data, I can however add some sort of weekly cleanout of these database fields where "confirmed" = 0.

我将如何自动执行此操作?有没有办法每周、每月、每年运行这样的查询?

How would I go about doing this automatically? Is there a way to run a query like this on a weekly, monthly, yearly basis?

如果我补充说该网站存储在我无法访问盒子本身的受限共享服务器上怎么办?

What if I added that the website is stored on a restricted, shared server where I have no access to the box itself?

推荐答案

您可以使用 CRON 来执行此工作.但是如果你需要从未完成的订单中清理你的数据库只是为了向人类显示已完成的订单并且你不将它们导出到其他地方(例如经理每天访问一次后端并手动查找完成的订单),我建议你不要雇用CRON 为此.您可以添加几行代码,以便在每次访问后端时从数据库中删除旧条目.

You can use CRON to perform this job. But if you need to clean your database from incompleted orders only to show completed ones for humans and you don't export them to other places (e.g. manager visits backend once per day and looks for completed orders manually), i suggest you not to hire CRON for this. You can add few lines of code which will remove old entries from database each time backend was accessed.

DELETE 查询的执行速度非常快,因此不会出现性能问题.真正的数据删除将仅根据请求执行.此外,您不需要拥有 CRON(一些廉价的托管服务提供商不允许访问此服务).

DELETE queries are executed really fast so there will be no problems with perfomance. Real data deletion will be performed only by request. Also you don't need to have CRON (some cheap hosting providers do not give access to this service).

这篇关于PHP MySQL - 每周一次的操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆