I have a Mysql database which contains the status of many orders and where they are located. Im looking for a way to notify my customer on the update of the status of their order.
Basically everytime the column "status" would be changed ( could be done with a trigger of some sort ) , trigger an event that would somehow be able to call an external script (preferably PHP) to either text or email my customer that their order has been updated and that the status is now X, if completed , tell them to come pick it up.
I've read around that triggering script from a mysql trigger is extremely bad pratice but I'm wondering if there are other options to do something like this.
Any suggestions?
Related
First greetings to all. Secondly I'm sorry I don't provide source or something but it is because simply I don't have yet.
I just confronted the following issue and need some help and some starting points.
I have a form which submit some data in mysql and save status pending(0) and is working great. What I wonder how can be done is after user submit the form how to trigger another php file which must do following actions on background
pull data from api periodically and check for status changes. Once
the status is changed to Not Pending to update database with new
status.
How can be done this? And to be more fun (for me) this script will update orders, so there would be multiple orders.. Also I'm limited from my hosting provider to not use cronjobs and js..
I need to be able to determine what database fields were changed in a mysql update and then log that change to another db table to eventually display to the user.
This application is for a system that tracks customer orders. It's developed in CodeIgniter, but I don't think that's necessarily relevant unless CI has some built-in library that could be helpful.
For example, here is where the database update occurs:
$this->db->update("orders",$this->input->post());
I can easily follow this up with an insert on the "events" table that says something like "Order Updated", but I have no way to determine what part of the Order was actually updated. I would like to be able to instead log something like "Order Status Updated" or "Order Quantity Updated".
How can I determine which db fields were changed in the mysql update? The answer doesn't have to be in CodeIgniter...raw php/mysql is fine.
I have a script that is written in PHP. It uses MySQL database to store records.
Basically, I have team of users that are making random calls to a different business. I want to add list of phone number in a queue "pool table". The system will need to assign the new call to the user. Now If a user is already working on a phone call I don't want another user to start calling the same number. I need a solution to prevent 2 people having the same record assigned to them. So if phone number 000-000-0000 is assigned to the user X the same record will be skipped and the next one in line get assigned to the next available user.
This table will be accessed a lot so I need a good solution that will prevent 2 people from working on the same record and also not cause system issues.
One way I can think of but looking for a better solution is
open transaction
select a call where record status is available
update that call by changing the status from records available to record pending.
commit transaction.
If the use completed the call then updated with a status of completed otherwise make the record available again.
what are other solution available for me?
Thanks
Without a little more information about the workflow, it's hard to know what to suggest, but it sounds like users are interacting with the application somehow while they are taking calls...true??
If so, you must have some way for the user to alert the system they are ready for a call.
ie...
I just started my shift... Deal me a number.
Or...
Submit notes from last call... click submit and Deal me another number.
In this scenario, it seems like it should pretty easy to just let the users "request" the next number. You could probably just insert the users id on that record so it shows in their queue.
I am working on a module in PyroCMS which uses Codeigniter. In this module users submit some sort of order at front-end and the moderator of the site will be notified and checks the order at the back-end, then he updates the row and the user is notified about the change. All done right now.
I am going to make things a little automatic. The process of supplying the order which is an electronic good like document file, etc is to search the other server ( ftp ) for the order and bring it to the main server.
So, I propose this workflow:
insert the row to the table ( front-end )
initialize the robot to search the ftp server and set a flag that the
robot is processing the order.
if found: transfer the file to the server and update the row and
flag.
if not found update the flag and let the manager do the rest of the
job.
Now, The thing is that I think it is not a good idea to put the robot code into the same controller and fire the robotic task with the http request from user. I mean, the form is submitted and I just want to insert the row and end the process and notify the user that it is submitted, then the robotic task should be done at the background.
Now we can update the workflow like:
insert the new row
notify the user that your order is submitted. and let user go.
run the background process (trigger it) to search the ftp server and
update the row upon success or do nothing upon error.
how can I do this type of background proccess? any idea or experience?
You can put your robot code to other php file and then run that php file using the php's system or exec command after successfull form submission. This will run like new php thread.
Hope this helps.
If you have ever been to a sms messaging site, you probably have seen that users can decide they want to schedule the sending of their sms message at a later time.
So a user logs on to the site (a real life example is at http://www.smslive247.com or http://routesms.com), composes the sms and clicks on "send message at a later time" radiobox. This gives users a datetime field that you can then pick what date and time you want the message to be dispatched (as well as ability to change the timezone).
Basically, users can schedule the sending of sms.
I'm also designing a similar site and wondering if anyone can tell me how this is done.
Thanks.
Use a message queue, for example in a database, that gets read by a separate process (a service, or cron job for example) that processes the records and sends the message.
One approach is to store the message and write a service to send queued messages. You can store the messages in a database.
One approach is to use a database.
Create a table with a column that contains the datetime the message should be sent, and another column with the message.
From a background thread (or even another process, such as a Windows Service or a SQL Agent task), wake up every once in a while, read the top row in the table, and see if it's time to execute it. Something like:
CREATE TABLE MyQueue (
TimeToExec DATETIME NOT NULL,
Message NVARCHAR(MAX) NOT NULL
)
INSERT INTO MyQueue VALUES(GETDATE(), N'message')
;WITH MYCTE AS (
SELECT TOP 1 Message
FROM MyQueue
WITH (ROWLOCK, READPAST)
WHERE TimeToExec <= GETDATE()
ORDER BY TimeToExec
) DELETE FROM MYCTE
OUTPUT DELETED.Message