php code architecture thoughts and suggestions
Posted on 2003-10-31
I am working on a php project. Currently I have a php script that display a fair amount of text, email addresses atec on a page. The user has an option to edit it. If they do, a mail script which I have written is called and it parses a mail together and sends it out using the PHPMailer class.
after the mail is sent the user is moved back to another page.
This system is used to track work (here at work) and is used very often and many emails are sent from it. All the data is stored in a mysql database.
Here is my dilemma:
When a user sends out email, the script does not return until my script has parsed the message together and theclass file has connected to the mail server and sent the message. This can cause a very noticiable delay: 2-10 seconds usually, and if there are a few attachments, or large attachments, much longer.
What I would like to discuss:
How I can move this load of off the users browser and have "the server" take care of it.
Two ways I have thought of so far are :
having a php script which looks for some entry in the database and when it sees it, shoot off a message and change that value in the db. This would be done using a script that is run say every 5 minutes on the server via a batch file??
Secondly, which would probably be more preferrable is to have the mysql database call a php script via a command window when a certain value is changed (i.e a trigger function).
Now, i know mysql does not yet have triggers, but maybe some of my fellow coders here have already thought of a way around this or would like to think of a way.
3rdly, I would love to hear any other ideas anyone has on this topic.