How can we dynamically listen for database changes?

Source: Internet
Author: User
How can I dynamically listen for database changes? I want to make a shopping website and want to prompt the message "someone bought your product" when someone buys the product, but how can I listen for database changes? Should the regular query database occupy a lot of resources? (1 time per second ). Thank you! ------ solution ------------------ I understand what the landlord means. he means how to dynamically listen to database changes when someone places an order on the current server.
I want to create a shopping website and want to prompt the message "someone bought your product" when someone buys the product. but how can I listen for database changes? Should the regular query database occupy a lot of resources? (1 time/1 s ). Thank you!


------ Solution --------------------
I understand what the landlord meant. he meant that when someone placed an order on the current station, the background staff could immediately obtain the order information instead of refreshing the order.
Currently, I have the following methods,
1. write an email to send the email. when a customer places an order, the email is sent to the administrator's email when inserting the data. it is best to use QQ mail because QQ can remind you. In this way, when someone places an order, they will immediately know that, of course, they can also use text messages (but they need money and there is a delay ).
2. use JS setInterval to check whether the database has changed every three seconds. if there is any, you can make a QQ or TradeManager prompt to prompt the background staff for a new order, that's what I do.
Paste my code:
Var int = setInterval ("clock ()", 20000 );
Function clock (){
$ ("# Call_p" ).html ('
  • Refreshing screen...
  • ');
    Var url = "extend/new_dd.php? Cache = "+ Math. random ();
    $. Get (url, function (result ){
    $ ("# Call_p" ).html (result );
    });
    }

    3. JS setInterval is also used, but it is not used to query the database. when a customer places an order and inserts data, the content in $ _ SESSION [odrer_state] is changed to 1, then we use JS setInterval to get the content every three seconds. if it is set to 1, we will not submit the order to the background personnel, if a background engineer sees the key points and then changes the content of $ _ SESSION [odrer_state] to 0. In this way, database resources are not consumed due to excessive queries.

    In fact, there are many methods, depending on how you use the most appropriate. Attach the carrying diagram of this function of my website

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.