PHP:每周和每隔一周安排(预定)
我对我正在接管的项目有疑问。我正在转换其他人编写的 MS Access 应用程序并将其转换为 MySQL/PHP Web 应用程序。大部分工作已经完成,但是,当涉及到该应用程序的调度部分时,我处于停滞状态。
我需要能够制定一个要完成的工作的“时间表”。因此,我将运行一个报告,它会搜索数据库中的某一天,例如 2011 年 3 月 15 日。它将基于那一天的数据库记录构建此报告,并为其构建一个针对打印而优化的报告。
该应用程序本身最初是为 MS Access 编写的,因此默认情况下,MS ACCESS 允许 GUI 复制/粘贴。话虽这么说,最终用户完成调度的方式是,他们将从模板中复制/粘贴来为该特定客户构建“每周”调度。例如,假设有一个每周注册的新客户,最终用户将转到模板 (MS Access) 复制预定义为“每周”的所有行,然后将其粘贴到客户部分。
显然,我不想也不应该走那条路。
我想知道的是,因为这是我做过的最大的项目,而且我正在做这个自由职业(我把编程作为一种爱好 - 这是一个恩惠),是否有人可以给我指出一个方向这会让我走上正轨。
“客户”要么按照“每周”的时间表,要么按照“每隔一周”的时间表。在数据库中,有一个“current_schedule”选项告诉我它们是“每周”还是“每隔一周”,但是让网络应用程序真正基于此“构建”时间表会很好,几乎就像“即将到来的约会”或类似的内容。我以前见过这样做的,但我只是不知道其中的逻辑或方向。此外,我想重新安排某些项目,一旦我对之前的问题有了基本的了解,这应该很容易制定时间表并将其显示在屏幕上。
我目前唯一能想到的是构建一个脚本来获取数据库选项,然后将计划“构建”到数据库中。问题是,如果我想更改客户,然后再次运行“调度程序构建器”,它将把一切搞乱 - 或者我可以对其进行检查,这将检查它是否已经构建并且然后“保护”该客户免遭重建,但这似乎比需要的工作更多。我可能是错的,这就是为什么我希望你们至少给我一些想法。
像往常一样,提前致谢。
I have a question regarding a project I'm taking over. I'm converting a MS Access application that someone else wrote and converting it to a MySQL/PHP web app. Most of it has been completed, however, I'm at a standstill when it comes to the scheduling part of this application.
I need to be able to have a "schedule" for work to be done. So, I would run a report, and it would search the database for a certain day, for example, March 15, 2011. It would build this based on database records for THAT day, and would build a report on it optimized for printing.
The application itself was originally written for MS Access, so therefore, by default, MS ACCESS allows for GUI copy/paste. With that being said, the way that the scheduling was done by the end user is, they would copy/paste from a template to build the "weekly" schedule for THAT particular customer. For example, say theres a new customer that signs up for weekly, the end user would go to a template (MS Access) copy all the rows that would predefined as "every week" and then paste it into the customer's section.
Obviously, I don't want, nor should I go that route.
What I'm wanting to know, since this is the biggest project I've ever done, and I am doing this freelance (I do programming as a hobby - and this is a favor), is if anyone could point me into a direction that would get my on the right track.
The "customers" are either going to be on a "weekly" schedule or an "every other week" schedule. In the database, there is a "current_schedule" option that tells me if they are "weekly" or "every other week", but it would be nice to have the webapp actually "build" out the schedule based on that, almost like "upcoming appointments" or something like that. I've seen this done before, but I just don't know the logic or the direction to go in. Additionally, I will want to reschedule certain items, which that should be easy once I get a basic understanding of my previous question on building the schedules and displaying them on the screen.
The only thing I can currently think of is building a script that would get the database option, and then "build" the schedules into the database. Problem with that is, if I want to change a customer, and then the "scheuduler builder" is run again, it will mess everything up - or I could build a check into that, that would check to see if it was already build and then "protect" that customer from being rebuilt, but it seems like more work than needed. I could be wrong, and that's why I'm looking to you guys to at least give me some ideas.
Thanks in advanced, as usual.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果 PHP/MySQL 应用程序在 Windows 上,您应该使用任务计划程序每周运行一个 Perl 或 PHP 脚本,检查数据库中需要更新的内容,然后执行更新。我推荐 Strawberry Perl,Windows 下的 Perl 解释器。您只需安装它,安装 DBI 模块,然后通过该脚本由操作系统安排每周运行。该脚本将根据在数据库中看到的内容运行不同的任务。
如果安装在 UNIX 机器上,您将执行完全相同的操作,只不过不是通过“任务计划程序”安排每周运行 perl 脚本,而是通过 cron 来执行。请参阅
man crontab
或man cron
。 Perl 解释器内置于每个 UNIX 系统中,因此您只需确保安装了 DBI 模块即可。这就是我一直在数据库上运行定期任务的方式:通过操作系统安排脚本。If the PHP/MySQL app is on windows, you should use task scheduler to run a perl or PHP script every week, to check what needs to be updated in the database, and to do it. I recommend Strawberry Perl, the perl interpreter for windows. You simply install it, install the DBI module, and run your updates through that script which is scheduled by the OS to run weekly. The script would run diffeent tasks based on what it saw in the database.
If the setup is on a UNIX machine, the you would do the exact same thing, except that instead of scheduling a weekly running of a perl script through "Task Scheduler", you would do it through cron. See
man crontab
orman cron
. The perl interpreter is built into every UNIX system, so you would only need to make sure the DBI module is installed. That's how I have always run periodic tasks on my databases: scheduled scripts through the OS.